@ewb/reach-react
Version:
React Resource and Fetch stuff
18 lines (17 loc) • 756 B
TypeScript
import { Dispatch, SetStateAction } from 'react';
import { IReachOptions } from '@ewb/reach';
import type { IUseProps } from './types';
export declare type IUsePatchProps<T, E> = Pick<IUseProps<T>, 'defaultBody' | 'onPatch' | 'onError'>;
interface IUsePatchState<T, E> {
busy: boolean;
data?: T;
error?: E;
}
export declare type IUsePatchFn<T> = <S = unknown>(id: string, body: Partial<T>) => Promise<T | null>;
export declare type IUsePatchRet<T, E> = [
state: IUsePatchState<T, E>,
patch: IUsePatchFn<T>,
setState: Dispatch<SetStateAction<IUsePatchState<T, E>>>
];
export declare function usePatch<T, E = any>(path: string, props?: IUsePatchProps<T, E>, reachProps?: Omit<IReachOptions, 'method'>): IUsePatchRet<T, E>;
export {};