UNPKG

@ewb/reach-react

Version:
18 lines (17 loc) 651 B
import { Dispatch, SetStateAction } from 'react'; import { IReachOptions } from '@ewb/reach'; import type { IUseProps } from './types'; export interface IUseGetProps<T> extends Pick<IUseProps<T>, 'onGet' | 'onError'> { disableInit?: boolean; } export interface IUseGetState<T, E> { busy: boolean; data?: T; error?: E; } export declare type IUseGetRet<T, E> = [ state: IUseGetState<T, E>, get: () => Promise<T | null>, setState: Dispatch<SetStateAction<IUseGetState<T, E>>> ]; export declare function useGet<T, E = any>(path: string, props?: IUseGetProps<T>, reachOptions?: Omit<IReachOptions, 'method'>): IUseGetRet<T, E>;