@ewb/reach-react
Version:
React Resource and Fetch stuff
11 lines (10 loc) • 706 B
TypeScript
import { FormEvent } from 'react';
import { IReachOptions } from '@ewb/reach';
import { IUseReachProps, IUseReachState } from './useReach';
export declare type IUseReachFormOnSubmitFn<T> = (e: FormEvent<HTMLFormElement>) => Promise<T | null>;
export declare type IUseReachFormGetIdAndBodyFn<T> = (data: Partial<T>) => IUseReachFormIdAndBody<T>;
export declare type IUseReachFormIdAndBody<T> = {
id?: string | null;
body: Partial<T>;
};
export declare function useReachForm<T, E = any>(path: string, getIdAndBody: IUseReachFormGetIdAndBodyFn<T>, props?: IUseReachProps<T>, reachOptions?: Omit<IReachOptions, 'method'>): [state: IUseReachState<T, E>, onSubmit: IUseReachFormOnSubmitFn<T>];