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
extended-salmon•12mo ago
useInfiniteQuery does this
deep-jadeOP•12mo 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.
extended-salmon•12mo ago
UseInfiniteQuery's data contains all pages, you can freely access them and update them through
setQueryData