Skip to main content

AsyncDataLoaderT

import { type AsyncDataLoaderT } from '@dr.pogodin/react-global-state';

The AsyncDataLoaderT type is the signature of a valid data loader function for the useAsyncData() hook.

It is defined as a generic type:

export type AsyncDataLoaderT<DataT>
= (oldData: null | DataT) => DataT | Promise<DataT>;

Generic Parameters

  • DataT — The type of data loaded by the loader function.

Arguments

  • oldDataDataT | null — The previously loaded item, if any; or null.

Result

The data loader function must either return a Promise resolving to a DataT value, or just return a DataT value directly.