T
TanStack15mo ago
rival-black

Pagination with only one query key

I actually go through the docs regarding react query pagination. But somehow, I have a requirement to implement one only query key. My current implementation was to through queryClient.setQueryData() just to override the cache. Appreciate any advise regarding this one. Thank you very much.
3 Replies
flat-fuchsia
flat-fuchsia15mo ago
useInfiniteQuery does this
rival-black
rival-blackOP15mo ago
@Tim Appreciate the quick response tim. However, when I using useInfiniteQuery hook I'm having challenge when I do optimistic update/ invalidate queries after mutation success. When I use this hook the shape of data was different from normal useQuery. I have a scenario where I can update the cache even when I'm not on the active page of the useinfinitequery.
flat-fuchsia
flat-fuchsia15mo ago
UseInfiniteQuery's data contains all pages, you can freely access them and update them through setQueryData

Did you find this page helpful?