Infinite query refetch with pagination reset #5692
-
BackgroundHi there, we are using TQ for a React Native project. Let's say we have an infinite scroll list like a News Feed screen, and the infinite query pagination size is 10 (we tend to keep pagination size small for list performance reason).
When the list size grows bigger, I don't think it's good that we have that many requests done to the app each time refetch happens (of course we can disable Secondly, for pull to refresh an infinite scroll list, I don't think we actually need to refetch all pages, it's perfectly fine that we only refetch the first page and remove the rest of pages from the cache, so the infinite scroll history will just be reset, which is a pretty common behaviour in mobile app. There was a similar discussion on @TkDodo's Twitter early this year, see https://twitter.com/hirbod_dev/status/1624699469076787202 WorkaroundCurrently we have a utility function like
and we just call it before triggering the pull to refresh, like
It does work, but I'm just wondering if this is the best way to handle case like this? ProposalMaybe we can add another
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Huge +1 for this, I feel it is a pretty big gap in core functionality for infinite queries if there's no simple out-of-the-box way to be able to say "on refresh, please kill all pages from the cache and give me a fresh new first page" |
Beta Was this translation helpful? Give feedback.
-
yes, this is the best way to handle the case. Note that we have removed |
Beta Was this translation helpful? Give feedback.
-
@mk-nickyang Thanks to you I was able to solve the problem and this is how I solved it.
I just need this method to solve it . |
Beta Was this translation helpful? Give feedback.
yes, this is the best way to handle the case.
Note that we have removed
refetchPage
in v5 in favor of themaxPages
option. Your proposal has the same drawback asrefetchPage
has - it only works for programmatic invocations, but not automatic ones likerefetchOnWindowFocus
.