T
TanStack3y ago
rival-black

Don't refetch if there is data in the query cache

My goal is simply to not refetch a query if there exists data in the queryCache. I am using a PersistQueryClientProvider which is successfully using the persisted query client from local storage when start the app. However, if there is data in the local storage related to that query I want to disable refetching on mount and in general.
3 Replies
rival-black
rival-blackOP3y ago
I just want to use the data directly from the local storage which was then put in the query cache without any chance of a refetch
ratty-blush
ratty-blush3y ago
staleTime: Infinity
rival-black
rival-blackOP3y ago
Interestingly enough doesn't work - my query defaults: refetchOnReconnect: false, refetchOnWindowFocus: false, refetchOnMount: false, networkMode: 'online', cacheTime: 0, staleTime: Infinity, and the query in question has a cacheTime of infinity the query is initially not enabled, but then becomes enabled when certain prerequisite data becomes available. will this trigger a refetch? also the query in question is an infinite query

Did you find this page helpful?