Skip to content
Discussion options

You must be logged in to vote

when refetching, useInfiniteQuery always calls getNextPageParam for every fetch that isn't the first page. So in your scenario, when a refetch happens, we first fetch page1 with the stored pageParam, which is probably the initialPageParam, which seems to be empty string or null in your case, leading to a fetch for /records. That will return A,B,D.

Then, for the second page, we don't use the stored param C, but we call getNextPageParam for that page. In there, your logic will probably return D, because that's the current value of the first page. That's how we can make the second fetch with lastId=D. We'll continue this for all pages, or until undefined is returned from getNextPageParam.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@michtnt
Comment options

Answer selected by michtnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants