use-async-resource
Version:
A custom React hook for simple data fetching with React Suspense
11 lines (10 loc) • 645 B
TypeScript
export declare type ApiFn<R, A extends unknown[] = []> = (...args: A) => Promise<R>;
export declare type UpdaterFn<A extends unknown[] = []> = (...args: A) => void;
declare type DataFn<R> = () => R;
declare type LazyDataFn<R> = () => R | undefined;
export declare type ModifierFn<R, M = unknown> = (response: R) => M;
declare type ModifiedDataFn<R> = <M>(modifier: ModifierFn<R, M>) => M;
declare type LazyModifiedDataFn<R> = <M>(modifier: ModifierFn<R, M>) => M | undefined;
export declare type DataOrModifiedFn<R> = DataFn<R> & ModifiedDataFn<R>;
export declare type LazyDataOrModifiedFn<R> = LazyDataFn<R> & LazyModifiedDataFn<R>;
export {};