@figliolia/react-hooks
Version:
A small collection of simple React Hooks you're probably rewriting on a regular basis
12 lines (11 loc) • 590 B
TypeScript
import type { Callback } from "../Types";
export declare const useLoadingState: () => {
loading: boolean;
success: boolean;
error: string | boolean;
setState: <T extends ILoadingStateKey>(state: T, value: ILoadingStateValue<T>) => void;
resetState: () => void;
};
export type ILoadingStateKey = "error" | "loading" | "success";
export type ILoadingStateValue<T extends ILoadingStateKey> = T extends "error" ? boolean | string : boolean;
export type ILoadingStateSetter<T extends ILoadingStateKey = ILoadingStateKey> = Callback<[state: T, value: ILoadingStateValue<T>]>;