Replies: 2 comments
-
Hi 👋 Please can you provide a minimal reproduction or the relevant code please? If you've configured the query to cache infinitely, it shouldn't refetch unless something else is at play here such as the query key changing. |
Beta Was this translation helpful? Give feedback.
-
There is no automatic refetch after mutations. It only refetches if you call |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
In my case a mutation will invalidate an object on the backend so having a new fetch would imply an error changing the UI, and I don't want this.
I tried:
enabled
on the query, if my boolean is set after the mutation success, the query has already started to fetchrefetchOnMount: false, refetchOnWindowFocus: false, refetchOnReconnect: false
but it seems it does not apply to post-mutationstaleTime: Infinity, cacheTime: Infinity
as mentioned by @TkDodo in https://stackoverflow.com/questions/71282427/how-to-fetch-user-details-only-once but it does not prevent the refetch after mutationI'm a bit loss, what's the magic trick? On my side it would be acceptable otherwise to only fetch once even if it's not ideal.
(I saw a
isMutating
trick to use onenabled
, it's not what I was expecting since I want to block fetching after a success, but maybe I can deal with that)Thank you,
EDIT: I'm using
@tanstack/react-query
Beta Was this translation helpful? Give feedback.
All reactions