Skip to content

How do you invalidate a single page of useInfiniteQuery() and make sure only that page gets refetched ? #6691

Answered by TkDodo
bikalpaduwadi asked this question in Q&A
Discussion options

You must be logged in to vote

Here, I just want to invalidate and refetch data of 5th page. Is there any way to achieve this ?

no, not possible anymore (we removed refetchPage) because it's not how infinite queries were intended to be used. They are one cache entry, chunked up into multiple fetches. That's why you can't pass something like queryKey: ['data', 5]. The key in the cache is just data.

If you only refetch one page of the 5, and that yields new data, you will have duplicate or missing entries. The pages are a linked list where each one builds on top of the next.

If you want separate cache entries for each page, you can do useQueries and create an array with the length that you want, then concatenate the pa…

Replies: 3 comments 7 replies

Comment options

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

Comment options

You must be logged in to vote
2 replies
@ialwayswatching
Comment options

@TkDodo
Comment options

Answer selected by bikalpaduwadi
Comment options

You must be logged in to vote
4 replies
@TkDodo
Comment options

@wpp-roman-gryndii
Comment options

@sedgwickz
Comment options

@TkDodo
Comment options

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