You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an infinite query becomes stale and needs to be refetched, each group is fetched sequentially, starting from the first one. This ensures that even if the underlying data is mutated, we're not using stale cursors and potentially getting duplicates or skipping records. If an infinite query's results are ever removed from the queryCache, the pagination restarts at the initial state with only the initial group being requested.
Now the problem is that when ever the query needs to be refreshed I want React Query to only refetch the first page and remove other pages from cache, I can react my custom refresh function to do this but when React Query refreshes on it's own it will still refetch all the pages.
Use case is that if there is a chat app and the user scrolls up and loads a lot of previous chat pages, when the query has to be refetched all those pages will have to be refetched simultaniously.
Maybe this can be fixed by allowing staleTime and cacheTime per page or something like initialStaleTime and initialCacheTime
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I saw this in the docs
What happens when an infinite query needs to be refetched?
When an infinite query becomes
stale
and needs to be refetched, each group is fetchedsequentially
, starting from the first one. This ensures that even if the underlying data is mutated, we're not using stale cursors and potentially getting duplicates or skipping records. If an infinite query's results are ever removed from thequeryCache
, the pagination restarts at the initial state with only the initial group being requested.Now the problem is that when ever the query needs to be refreshed I want React Query to only refetch the first page and remove other pages from cache, I can react my custom
refresh
function to do this but when React Query refreshes on it's own it will still refetch all the pages.Use case is that if there is a chat app and the user scrolls up and loads a lot of previous chat pages, when the query has to be refetched all those pages will have to be refetched simultaniously.
Maybe this can be fixed by allowing
staleTime
andcacheTime
per page or something likeinitialStaleTime
andinitialCacheTime
Beta Was this translation helpful? Give feedback.
All reactions