T
TanStack3y ago
genetic-orange

Pagination and searching together

Hi, amazing library. I'm looking for a way to achieve both pagination and searching together (with caching features of react query, of course) but I couldn't find a specific example since my usage is also specific. What is the most used pattern for such task or are there any resources you recommend?
4 Replies
absent-sapphire
absent-sapphire3y ago
- current page goes into the queryKey - filters go into the queryKey there is nothing special about that combination
genetic-orange
genetic-orangeOP3y ago
so this is actually possible with single useQuery right? I think I understood, my endpoint looks like /api/v1/customers?page=1&name=customerName, so I believe queryKey should take both page and name states as far as I understood, useQuery acts like useEffect and reruns the query when queryKeys are updated
absent-sapphire
absent-sapphire3y ago
yep
genetic-orange
genetic-orangeOP3y ago
alright, thanks 👍

Did you find this page helpful?