@ewb/reach-react
Version:
React Resource and Fetch stuff
16 lines (15 loc) • 675 B
TypeScript
import { Dispatch, SetStateAction } from 'react';
import { IReachOptions } from '@ewb/reach';
import type { IUseProps } from './types';
export declare type IUsePostProps<T> = Pick<IUseProps<T>, 'defaultBody' | 'onPost' | 'onError'>;
export interface IUsePostState<T, E> {
busy: boolean;
data?: T;
error?: E;
}
export declare type IUsePostRet<T, E> = [
state: IUsePostState<T, E>,
post: (body: Partial<T>) => Promise<T | null>,
setState: Dispatch<SetStateAction<IUsePostState<T, E>>>
];
export declare function usePost<T, E = any>(path: string, props?: IUsePostProps<T>, reachOptions?: Omit<IReachOptions, 'method'>): IUsePostRet<T, E>;