UNPKG

@darwish/hooks-core

Version:

20 lines (19 loc) 594 B
import type { Options } from '../useRequest'; type States<T> = { data: T | null; loading: boolean; error: any; }; type DataStats<T> = States<T>['data']; export default function useFetch<TData = null, TParams extends any[] = []>({ service, options, }: { service: (params: any[]) => Promise<TData>; options?: Required<Options<TData, TParams>>; }): { data: TData | null; loading: boolean; error: any; run: (runParams: any) => void; mutate: (data: TData | ((prev: DataStats<TData>) => DataStats<TData>) | null) => void; cancel: () => void; }; export {};