About useInfiniteQuery
This is a post about useInfiniteQuery (infinite scrolling).
What is infinite scroll?
A user experience approach where content continues to load when the user reaches the bottom of the page.
Uses
It is primarily used in pagination. You use it when you want to show a large amount of data at once while minimizing the userโs clicks.
- Itโs easy to think of it as a way of describing an action: you bring up a certain number of items and press a button to load a set of data. The infinite scrolling should stop when the data has been loaded. This way, the infinite scrolling allows for the personalization that users want for their options.
How to use
- insert queryFunction and queryParams into the properties of useInfiniteQuery.
- in queryFunction, enter the infinite scroll target API, i.e. the dataset you want to fetch.
- for queryParams, enter the variables you want to store for a fixed number of rows of data.