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
I am currently using V4 (stuck on React 17) and have the following scenario:
I am using useInfiniteQuery and have the following requirements:
I have a queries with this structure: ['myUniquePrefix', 'my multiple complex filtering string result', 'myUniqueWhateverEntityId']
It is a table and it has various filters etc.
For 2 min all of the queries derived from 'myUniquePrefix' must be cached (staleTime)
After 2 min I need to mark all queries derived from my 'myUniquePrefix' as stale and ensure to have just page 1 is refetched once a user triggers a new request.
I thought that I could just combine invalidateQueries + refetchType: 'none' + refetchPage to ensure that I would mark all queries as stale and still ensure to refetch just the first page of each query (in case any of them have more than 1 page saved).
Result: It invalidated, but it still fetches all pages saved in cache.
So this made me go a BIG way around to solve the issue.
I had to have staleTime & cacheTime as Infinity and manually manage cache & query state (invalidate) manually in an interval callback + lazy invalidation of active queries. All manually. It feels really bad to need to write so much code for something that should work out of the box.
My hopes here is that I am totally wrong and there is a very simple way to achieve what I want =D
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently using V4 (stuck on React 17) and have the following scenario:
useInfiniteQuery
and have the following requirements:I have a queries with this structure:
['myUniquePrefix', 'my multiple complex filtering string result', 'myUniqueWhateverEntityId']
It is a table and it has various filters etc.
'myUniquePrefix'
must be cached (staleTime)'myUniquePrefix'
as stale and ensure to have just page 1 is refetched once a user triggers a new request.I thought that I could just combine
invalidateQueries
+refetchType: 'none'
+refetchPage
to ensure that I would mark all queries as stale and still ensure to refetch just the first page of each query (in case any of them have more than 1 page saved).Docs here for refetchPage
Result: It invalidated, but it still fetches all pages saved in cache.
So this made me go a BIG way around to solve the issue.
I had to have
staleTime
&cacheTime
asInfinity
and manually manage cache & query state (invalidate) manually in an interval callback + lazy invalidation of active queries. All manually. It feels really bad to need to write so much code for something that should work out of the box.My hopes here is that I am totally wrong and there is a very simple way to achieve what I want =D
Beta Was this translation helpful? Give feedback.
All reactions