weird thing with showButton
I just got a weird behavior with a showButton
on one page I have showButton working well with the record.id shown as link, on another page, code is the same, I have no link.
I am connected to a strapi and with ant-design
3 Replies
Hi @SetiZ. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The
<ShowButton>
component in Refine uses Ant Design's <Button>
component and the show
method from useNavigation
under the hood. It is used to redirect the app to the show page with the record id route of the resource.
The recordItemId
is used to append the record id to the end of the route path. By default, the recordItemId
is inferred from the route params. If the recordItemId
is not correctly set or inferred, the button might not work as expected.
Here is an example of how to use it:
In this example, clicking the button will trigger the show
method of useNavigation
and then redirect the app to the show
action path of the resource, filling the necessary parameters in the route.
If you're experiencing issues with the <ShowButton>
on one page but not another, it could be due to a variety of factors. Here are a few things to check:
1. Ensure that the recordItemId
is correctly set or inferred on both pages.
2. Check if there are any differences in the route params between the two pages.
3. Make sure that the resource
prop is correctly set. The redirection endpoint is defined by the resource
's show
action path. By default, <ShowButton>
uses the inferred resource from the route.
If you're still experiencing issues, it might be helpful to compare the working and non-working code to identify any differences. If you can't find the issue, consider posting a detailed question on the Refine GitHub Issues page (https://github.com/refinedev/refine/issues) or the Refine Discord server (https://discord.com/channels/837692625737613362/1197200118529663046) for further assistance.
Sources:
- ShowButton Documentation (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/show-button)
- ShowButton recordItemId (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/show-button#recorditemid)
- ShowButton resource (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/show-button#resource)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@267689263246606336> kapa.ai is still learning and improving, please let us know how it did by reacting below
unwilling-turquoise•5mo ago
thank kapa.ai
I just found my error 🫣
on the layout I didn't have this part
show: "/companies/show/:id",
sorry for the useless ticket