-
In the web app that I am currently working on, I encounter a case that I need to invalidate a query to a data after it is mutated. So I naturally call What I am doing to make it work around is as following: await queryClient.cancelQueries(['user-application', applicationId]);
await queryClient.invalidateQueries(['user-application', applicationId]); My first question is that: is there any way we can easily find which observer automatically invalidate the query for me, which is unexpected? I have called the same invalidations on one key in many places, so it is hard to find. The second one is: the workaround above is not elegant, is that possible that we can have an option(or already exists but just I didn't know) that cancels the pending one and re-invalidate a query based on the key, assuming it is true that Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In v4, calling In v3, you can do:
to achieve the same thing. |
Beta Was this translation helpful? Give feedback.
In v4, calling
invalidateQueries
will, per default, cancel existing queries and re-run them.In v3, you can do:
to achieve the same thing.
https://tanstack.com/query/v4/docs/guides/migrating-to-react-query-4#consistent-behavior-for-cancelrefetch