UNPKG

@figliolia/react-hooks

Version:

A small collection of simple React Hooks you're probably rewriting on a regular basis

17 lines (16 loc) 672 B
import type { FormEvent } from "react"; import type { Callback } from "../Types"; import type { ILoadingStateSetter } from "./useLoadingState"; export declare const useFormState: (callback: IFormStateCallback) => { setState: <T extends import("./useLoadingState").ILoadingStateKey>(state: T, value: import("./useLoadingState").ILoadingStateValue<T>) => void; resetState: () => void; loading: boolean; success: boolean; error: string | boolean; onSubmit: (e: FormEvent<HTMLFormElement>) => void; }; export type IFormStateCallback = Callback<[ data: FormData, setState: ILoadingStateSetter, resetState: Callback ], void | Promise<void>>;