React Query: When to use useInfiniteQuery or usePaginatedQuery for pagination

1.6k views Asked by At

I have a table like this enter image description here

which renders paginated items. The exact number of the times is unknown at the time of the API being called. So for handling pagination of a table like this. it is better to use useInfiniteQuery or usePaginatedQuery from React Query?

I am really struggling to understand the differences of the use cases for these two APIs here

1

There are 1 answers

0
Rodrigo J Moura On

As far as I understand by reading a bit of the docs, usePaginatedQuery will return resolvedData that just equals the last successeful page's data, it won't concatenade the last page's data to the data you already had. On the other hand, useInfiniteQuery does this with fetchMore.