useful-custom-react-hooks
Version:
A collection of useful custom React hooks to simplify common tasks and enhance your React applications.
15 lines (14 loc) • 361 B
TypeScript
export declare const useFetch: <T>(url: string, opts?: IOpts) => IFetchResult<T>;
interface IFetchResult<T> {
data: T | null;
isFetching: boolean;
error: any;
refetch: () => void;
}
interface IOpts {
method?: Method;
body?: BodyInit | null;
headers?: HeadersInit | null;
}
type Method = 'GET' | 'POST' | 'PUT' | 'DELETE';
export {};