useForm
in useForm from "@refinedev/antd", how to refetch data when in "edit" and clone mode?
5 Replies
Hi @Belvis. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In
edit
and clone
modes, Refine uses the useOne
hook to fetch data. You can pass the queryOptions
options by passing the queryOptions
property. This property will only work in the edit
and clone
actions.
Here is an example of how to use it:
In the above example, the retry
option is set to 3
, which means the query will be retried 3 times in case of failure.
You can find more details in the documentation here (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-form#queryoptions) and here (https://refine.dev/docs/ui-integrations/mantine/hooks/use-form#queryoptions).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below
deep-jadeOP•10mo ago
@kapa.ai im not saying that refetch when it's fail, refetch when i want
Let me check the knowledge base for you. One moment! :books:
----------------------
In Refine, you can manually refetch data using the
refetch
function provided by the queryResult
object from the useForm
hook. Here's an example:
You can call refetch()
whenever you want to manually refetch the data.
Additionally, Refine provides a useInvalidate
hook that you can use to invalidate certain queries, which will cause them to be refetched. Here's an example:
In the above example, the detail
query for the posts
resource with an id of 1
is invalidated, causing it to be refetched.
You can find more details in the documentation here (https://refine.dev/docs/guides-concepts/faq#how-can-i-refetch-data) and here (https://refine.dev/docs/core/hooks/data/use-invalidate/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@353701348463738885> kapa.ai is still learning and improving, please let us know how it did by reacting below