Replies: 1 comment
-
you can get some insights from this discussion - #1670 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'm using useInfiniteQuery for a chat app on React Native. I pull first 10 messages on load, then fetching other N pages by scrolling down Flatlist. Everything works fine but I also use refetchInterval to refetch messages every 5 seconds. Of course I have several pages (usually have), useInfiniteQuery makes several requests to refetch each page on refetchInterval.
Of course it makes sense but actually refetching all pages only needed if the first page's first item ID is not equal to cached list's first item's ID (or comparing entire object). I can do this by disabling refetchInterval and instead make a separate request, compare item id's and refetch entire list if necessary. But before going into trouble and making big changes in my components, I wanted to ask if there is a better method to achieve this.
I noticed queryClient.setQueryData option in the documentation however as far as I can see it's best for mutating the cached data.
Edit : I realized increasing query limit and making other adjustments would be much better idea rather than this. By the way huge fan of React Query. Looking for the v5!
Beta Was this translation helpful? Give feedback.
All reactions