Is there a `useIsFetching` for all queries within a specific component and its children?
I have a web app that is a dashboard with several different tabs a user can navigate to. Each tab has its own content to load. Each tab is its own component and they all use React query to fetch their desired data. Each tab is a component itself.
I want to track the counts of queries running that were intiiated within those components.
1 Reply
broad-brown•3y ago
I'd use
useIsFetching with a query filter matching partial query keys. You can organize your query keys so that all the queries under the same tab start the same way:
['tab1', 'query1'], ['tab1', 'query2'] and then you can get the count of fetching queries under a single tab with useIsFetching({ queryKey: ['tab1'] })