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

Function getNextPageParam

packages/query-core/src/infiniteQueryBehavior.ts:152–165  ·  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

150 * @returns The next page param, or `undefined` if there are no pages yet.
151 */
152function getNextPageParam(
153 options: InfiniteQueryPageParamsOptions<any>,
154 { pages, pageParams }: InfiniteData<unknown>,
155): unknown | undefined {
156 const lastIndex = pages.length - 1
157 return pages.length > 0
158 ? options.getNextPageParam(
159 pages[lastIndex],
160 pages,
161 pageParams[lastIndex],
162 pageParams,
163 )
164 : undefined
165}
166
167/**
168 * 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