Skip to main content
Version: v8.0.0

UseInfiniteFetchOptionsType


Import
import { UseInfiniteFetchOptionsType } from "@hyper-fetch/react"

Preview​

type UseInfiniteFetchOptionsType<R,P,TSelected> = {
bounce?: boolean;
bounceTime?: number;
bounceTimeout?: number;
bounceType?: debounce | throttle;
dependencies?: any[];
dependencyTracking?: boolean;
disabled?: boolean;
keepPreviousData?: auto | preserve | clean;
maxPages?: number;
pagination: P;
refetchBlurred?: boolean;
refetchOnBlur?: boolean;
refetchOnFocus?: boolean;
refetchOnReconnect?: boolean;
refresh?: boolean;
refreshTime?: number;
revalidate?: boolean;
select?: (context: { items: PaginationItem<R, P>[]; pages: ExtractResponseType<R>[] }) => TSelected;
structuralSharing?: boolean;
suspense?: boolean;
throwOnError?: boolean | (error: ExtractErrorType<R>) => boolean;
uniqueBy?: Extract<keyof PaginationItem<R, P>, string> | (context: { item: PaginationItem<R, P> }) => unknown;
}

Structure​

UseInfiniteFetchOptionsType
NameTypeDescription
bounce
boolean

Waits for the request to settle before starting a new list, for filters changing while typing

bounceTime
number

How long new lists are bounced

bounceTimeout
number

Only for the throttle strategy - handling of the last bounce event

bounceType
debounce | throttle

Bounce strategy

dependencies
any[]

Refetches the loaded pages when any of these values change

dependencyTracking
boolean

Rerenders only when the values used by the component change

disabled
boolean

Disables fetching

keepPreviousData
auto | preserve | clean

What is shown while a new list loads its first page:

  • "auto" (default) keeps the previous list when only query params changed, clears it for another resource
  • "preserve" always keeps the previous list
  • "clean" always clears it
maxPages
number

Keeps only this many pages loaded. Pages at the opposite end are dropped and can be fetched again.

pagination
P

Which fields of the request page through the list. Every key is checked against the request types.

refetchBlurred
boolean

Keeps refreshing while the tab is not focused

refetchOnBlur
boolean

Refetches when the user leaves the tab

refetchOnFocus
boolean

Refetches when the user enters the tab

refetchOnReconnect
boolean

Refetches when the network is restored

refresh
boolean

Refetches the loaded pages on an interval

refreshTime
number

Refresh interval time

revalidate
boolean

Refetches pages restored from the cache on mount, even when they are not stale yet

structuralSharing
boolean

Keeps references of the unchanged parts of the list between updates

suspense
boolean

Suspends until the first page arrives. Later pages never suspend.

throwOnError
boolean | (error: ExtractErrorType<R>) => boolean

Throws the error to the closest Error Boundary once the page request settles. Pass a function to decide per error.

uniqueBy
Extract<keyof PaginationItem<R, P>, string> | (context: { item: PaginationItem<R, P> }) => unknown

Drops items repeated across pages, for lists that shift while scrolling. Name a field of the item or return the identity from a function.

select
(context: { items: PaginationItem<R, P>[]; pages: ExtractResponseType<R>[] }) => TSelected

Transforms the list used by the component. The cache stays shared with other hooks.