TanStackT
TanStack4y ago
7 replies
endless-jade

How to refetch data in useInfiniteQuery() - react query?

I have a list of items and I'm using useInfiniteQuery for pagination stuff, So I have a case where I can edit Item info and then re-fetch the list again to get the updated list of items,

current behavior:
using queryClient.refetchQueries

it replaces the prev data with the re-fetched data on the current page.

await queryClient.refetchQueries(['getUsualOrders'], { stale: true, });
using refetch.

it replaces the prev data with current page data without the updated data
Actually, it sends a request for the next page "that doesn't exist"

So how can i re-fetch the data and keep the previous data?
Was this page helpful?