combining useInfiniteQuery and usePaginatedQuery #734
-
Hi, const fetchProducts = (key, filters, offset) => {
// Perform fetch ...
}
function ProductsList() {
const [category, setCategory] = useState('foo')
const { data } = useInfiniteQuery(
['products', { category }],
fetchProducts,
{
getFetchMore: (lastGroup) => lastGroup.pagination.offset,
}
)
} When i apply a new filter and the key changed i want to have similar to |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Wouldn't it make sense to have this behavior by default? Seeing as infinite lists are the primary use case for useInfiniteQuery, and that such lists are often filtered. |
Beta Was this translation helpful? Give feedback.
-
This is a good idea. We'll do this in v3. I imagine that a "paginated" query will just be some type of modifier on the |
Beta Was this translation helpful? Give feedback.
This is a good idea. We'll do this in v3. I imagine that a "paginated" query will just be some type of modifier on the
useQuery
anduseInfiniteQuery
hooks that makes them lag the data behind for pagination :)