refetch data for table after mutation in create form component
how do i force refetch data for table after mutation is completed in create form component both have common parent component
2 Replies
Hi @tarang._. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, after a successful mutation, certain queries are invalidated by default which triggers a refetch of the data. This is handled by the mutation hooks such as
useCreate
, useUpdate
, useDelete
, etc.
For instance, when the useCreate
mutation runs successfully, it invalidates the list
and many
queries from the current resource by default. This means that if you use useList
or useMany
hooks on the same page, they will refetch the data after the mutation is completed.
Here is an example of how you can use the useCreate
hook:
In this example, after the mutate
function is called and the mutation is successful, the list
and many
queries for the "resource" will be invalidated and refetched.
You can also customize the scope of the invalidation by passing the invalidates
prop to the mutation hook. For example:
In this example, the list
, many
, and detail
queries for the "resource" will be invalidated and refetched after the mutation is successful.
For more information, refer to the refine documentation (https://refine.dev/docs/api-reference/core/hooks/data/useCreate/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@852840146495340564> kapa.ai is still learning and improving, please let us know how it did by reacting below