T
TanStack7mo ago
equal-jade

Prefetching previous pageParams for a useInfiniteQuery?

Lets say i have 2 previous cursors in cache (from a regular query) that I want to use on an useInfiniteQuery - how would I do this? Basically the useInfiniteQuery hook will fetch the current token, but it wont have the previous cursors and data in cache yet, I simply want to supply the previous tokens so it can populate pageParams and data from the fetch.
1 Reply
wise-white
wise-white7mo ago
As in you want to use a page param from a different query? Only way I can think of is to manually update your data https://tanstack.com/query/latest/docs/framework/react/guides/infinite-queries#what-if-i-want-to-manually-update-the-infinite-query
Infinite Queries | TanStack Query React Docs
Rendering lists that can additively "load more" data onto an existing set of data or "infinite scroll" is also a very common UI pattern. TanStack Query supports a useful version of useQuery called use...

Did you find this page helpful?