2 Replies
Hi @koop_g. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, there are several ways to get the current edit page resource ID in refine. Here are the main methods:
1. Using
useResourceParams
hook:
The useResourceParams
hook provides an easy way to get the current resource ID and other parameters.
This hook infers the ID from the route automatically. useResourceParams documentation
2. Using useForm
hook:
If you're using the useForm
hook (which is common in edit pages), it automatically reads the ID from the route:
useForm documentation (Ant Design)
3. Using useParsed
hook:
If you need to explicitly get the ID from the current URL:
useForm documentation (React Hook Form)
It's important to note that refine automatically infers the resource and ID from the current route in most cases. If you're using the standard routing conventions, you typically don't need to manually specify the ID.
If you need to set the ID programmatically, you can use the setId
function provided by hooks like useForm
:
useForm documentation (Mantine)
These methods should cover most scenarios for getting the current edit page resource ID in refine.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1327562833537400895> Kapa.ai is still learning and improving, please let me know how I did by reacting below.