Skip to content

API reference > @kontsedal/olas-react > useInfiniteQuery

useInfiniteQuery() function ​

Subscribe a component to an infinite query subscription a controller made with createQuery(ctx, infiniteQuery, …). One subscription covers the pages, the flattened items and the paging flags, and it is fine-grained the way useQuery is: a list that renders flat and hasNextPage does not re-render while isFetchingPreviousPage flips.

tsx
const { flat, hasNextPage, isFetchingNextPage, fetchNextPage } = useInfiniteQuery(api.feed)

{ suspense: true } suspends until the first page lands, with useQuery's rules.

Signature:

typescript
export declare function useInfiniteQuery<TPage, TItem>(subscription: InfiniteQuerySubscription<TPage, TItem>): UseInfiniteQueryResult<TPage, TItem>;

Parameters ​

Parameter

Type

Description

subscription

InfiniteQuerySubscription<TPage, TItem>

Returns:

UseInfiniteQueryResult<TPage, TItem>

Released under the MIT License.