React.js - TanStack Query InfiniteQuery very slow on refetch

188 Views Asked by At

I'm using @tanstack/react-query version 5 for my React.js App, and I have a page where I'm showing items and it's using pagination.

So for that purpose, I use useInfiniteQuery, but I notice that when I have multiple page of data loaded, if I try to refetch all the pages to keep my data up to date with the server, the page are refetch one by one asynchronously and so it's very slow.

How to make my query refetch synchronously on each page ? I didn't find anything on the internet. Maybe I should use the normal useQuery and use multiple query for each page (so basically I manage myself each page ?

Or maybe it's just my code that only show when all the pages are reload and not one by one through my loop ?

Here is my code showing the problem on CodeSandBox:

Edit tanstack-infinite-query-example-slow

Thank you

0

There are 0 best solutions below