Skip to main content
Version: v8.0.0

UseCacheOptionsType


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

Preview​

type UseCacheOptionsType<T,TSelected> = {
deepCompare?: boolean | typeof isEqual;
dependencyTracking?: boolean;
initialResponse?: CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>[data] | null;
select?: UseTrackedStateSelect<T, TSelected>;
structuralSharing?: boolean;
}

Structure​

UseCacheOptionsType
NameTypeDescription
deepCompare
boolean | typeof isEqual

Deep comparison function for hook to check for equality in incoming data, to limit rerenders.

dependencyTracking
boolean

If true it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.

initialResponse
CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>[data] | null

If cache is empty we can use placeholder data.

structuralSharing
boolean

Keep references of the unchanged parts of the selected data between updates (default true).

select
UseTrackedStateSelect<T, TSelected>

Pick or transform the part of the cached data used by the component. The hook rerenders only when the selected value changes, while the cache stays shared with other hooks.