global refetch
I have an edit page, that has 2 child components that both have useList and useCustom hooks inside of them.
i want to be able to refetch those hooks from the parent edit page, is there a streamlined way to do that?
2 Replies
Hi @biohazard#1521. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To refetch data from multiple hooks in child components from a parent component in refine, you have a few options:
Option 1: Use the
useInvalidate
hook
The most streamlined approach is to use the useInvalidate
hook, which allows you to invalidate queries and trigger refetching:
Option 2: Pass refetch functions as props
If you need more control, you can pass refetch functions from child components to the parent:
For custom queries
For useCustom
hooks, you need to set a specific query key to be able to invalidate them:
This approach is documented in the useCustom documentation.
Automatic refetching with mutations
It's worth noting that refine's mutation hooks (useCreate
, useUpdate
, useDelete
, etc.) automatically invalidate related queries by default. For example, when you use useUpdate
, it will automatically refetch list
, many
, and detail
queries for that resource, as mentioned in the useUpdate documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@680514070167683118> Kapa.ai is still learning and improving, please let me know how I did by reacting below.