-
Describe the bugHello, I'm using the library to implement pagination and invalidate data when making changes. This works well only if the changes I make and the useInfiniteQuery hook are on the same screen. However, if another query using useInfiniteQuery with the same queryKey is on a different screen (which I was on a few seconds ago and made the useInfiniteQuery call), and I invalidate the cache, the cache on the previous screen doesn't get updated. In fact, when using the library's dev tools, I can see that it's in an inactive state and doesn't fetch all the pages after invalidation. Project Structure: Views:
Is it possible to update the cache of a query even if it's not on the currently active screen? Your minimal, reproducible exampleNo reproducible demo Steps to reproduce
Then on
Expected behaviorIt should invalidate both endpoints, even when one of the screens is not in focus, but shortly before it was. How often does this bug happen?Every time Screenshots or VideosNo response Platform
Tanstack Query adapterreact-query TanStack Query version^4.36.1 TypeScript version^4.8.4 Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
invalidation does two things:
so if you go back to the if you want an immediate refetch of all matching queries, even the inactive ones, use |
Beta Was this translation helpful? Give feedback.
invalidation does two things:
so if you go back to the
overview
page, and that page mounts, there should be a refetch unless you've changed the default of therefetchOnMount
flag.if you want an immediate refetch of all matching queries, even the inactive ones, use
queryClient.refetchQueries
.