MCPcopy Create free account
hub / github.com/TanStack/query / getNextPageParam

Function getNextPageParam

packages/query-core/src/infiniteQueryBehavior.ts:149–162  ·  view source on GitHub ↗

* Computes the page param of the page after the last one, with the `getNextPageParam` option. * @param options - The infinite query options. * @param data - The current pages and page params. * @returns The next page param, or `undefined` if there are no pages yet.

(
  options: InfiniteQueryPageParamsOptions<any>,
  { pages, pageParams }: InfiniteData<unknown>,
)

Source from the content-addressed store, hash-verified

147 * @returns The next page param, or `undefined` if there are no pages yet.
148 */
149function getNextPageParam(
150 options: InfiniteQueryPageParamsOptions<any>,
151 { pages, pageParams }: InfiniteData<unknown>,
152): unknown | undefined {
153 const lastIndex = pages.length - 1
154 return pages.length > 0
155 ? options.getNextPageParam(
156 pages[lastIndex],
157 pages,
158 pageParams[lastIndex],
159 pageParams,
160 )
161 : undefined
162}
163
164/**
165 * Computes the page param of the page before the first one, with the `getPreviousPageParam`

Callers 2

fetchFnFunction · 0.70
hasNextPageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected