new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

TanStack Query · React · all subjects

infinite queries

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

usePrefetchInfiniteQuery hook signature

The usePrefetchInfiniteQuery hook takes an options object as its parameter. The signature is usePrefetchInfiniteQuery(options).

usePrefetchInfiniteQuery options: queryKey

The queryKey option is required. It accepts a QueryKey and specifies the query key to prefetch during render.

usePrefetchInfiniteQuery options: queryFn

The queryFn option accepts a function with signature (context: QueryFunctionContext) => Promise<TData>. It is required unless a default query function has been defined.

usePrefetchInfiniteQuery options: initialPageParam

The initialPageParam option is required. It accepts a TPageParam and specifies the default page param to use when fetching the first page.

usePrefetchInfiniteQuery options: getNextPageParam

The getNextPageParam option is required and has the signature (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null. When new data is received for the query, this function receives the last page of the infinite list of data, the full array of all pages, and pageParam information. It should return a single variable that will be passed as the last optional parameter to the query function, or return undefined or null to indicate there is no next page available.

usePrefetchInfiniteQuery return value

The usePrefetchInfiniteQuery hook does not return anything. It should be used only to fire a prefetch during render, before a suspense boundary that wraps a component that uses useSuspenseInfiniteQuery.

Give your agent this brain