Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

InfiniteQueryPageParamsOptions.md

32 lines1.7 KB

1---
2id: InfiniteQueryPageParamsOptions
3title: InfiniteQueryPageParamsOptions
4---
5​
6Defined in: [packages/query-core/src/types.ts:403](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L403)
7​
8## Extends
9​
10- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\>
11​
12## Extended by
13​
14- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)
15​
16## Type Parameters
17​
18### TQueryFnData
19​
20`TQueryFnData` = `unknown`
21​
22### TPageParam
23​
24`TPageParam` = `unknown`
25​
26## Properties
27​
28| Property | Type | Description |
29| ------ | ------ | ------ |
30| <a id="getnextpageparam"></a> `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. |
31| <a id="getpreviouspageparam"></a> `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. |
32| <a id="initialpageparam"></a> `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. |