-
When I'm using the useInfiniteQuery method, I've set the staleTime to 1 minute. I requested data for 5 pages and cached it. However, when the cache becomes stale, all 5 pages of data are refreshed simultaneously. How can I achieve refreshing only the first page of data and clearing the cache for other pages when the cache expires? The actual use case is: chat history, where users might load multiple pages of chat records. However, when new chat records appear, I want to refresh only the first page of data. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
anyone can help?best wishes |
Beta Was this translation helpful? Give feedback.
-
technically not true, they are fetched one after the other. But yes, they are all fetched.
spawn a What this will achieve however is that after 1 minute, you'll only see one page on your screen, even if you have seen 5 before that. But it seems like that's what you want? |
Beta Was this translation helpful? Give feedback.
technically not true, they are fetched one after the other. But yes, they are all fetched.
spawn a
useEffect
that listens toisStale
returned byuseQuery
, and callsetQueryData
to delete everything after the first page.What this will achieve however is that after 1 minute, you'll only see one page on your screen, even if you have seen 5 before that. But it seems like that's what you want?