Skip to content
Source
Sign inSign up
TanStack/query

Feature/infinite queries #5004

MergedTkDodomerged 27 commits intoalpha fromrefs/pull/5004/headmerged by TkDodo View on GitHub

Showing 39 changed files with 39 additions and 46 deletions (loading 36).

x
0 of 39 viewed, 39 left
10 additions and 41 deletionsdocs/react/guides/infinite-queries.mdModified
View file
@@ -103,42 +103,11 @@
​
When an infinite query becomes `stale` and needs to be refetched, each group is fetched `sequentially`, starting from the first one. This ensures that even if the underlying data is mutated, we're not using stale cursors and potentially getting duplicates or skipping records. If an infinite query's results are ever removed from the queryCache, the pagination restarts at the initial state with only the initial group being requested.
​
-## What if I need to pass custom information to my query function?
-​
-By default, the variable returned from `getNextPageParam` will be supplied to the query function, but in some cases, you may want to override this. You can pass custom variables to the `fetchNextPage` function which will override the default variable like so:
-​
-[//]: # 'Example3'
-​
-```tsx
-function Projects() {
- const fetchProjects = ({ pageParam = 0 }) =>
- fetch('/api/projects?cursor=' + pageParam)
-​
- const {
- status,
- data,
- isFetching,
- isFetchingNextPage,
- fetchNextPage,
- hasNextPage,
- } = useInfiniteQuery({
- queryKey: ['projects'],
- queryFn: fetchProjects,
- getNextPageParam: (lastPage, pages) => lastPage.nextCursor,