import React from "react";
type PromiseType
> = P extends Promise ? T : never;
type FunctionReturningPromise = (...args: any[]) => Promise;
export type UseAsyncState = {
loading: boolean;
error?: undefined;
value?: undefined;
} | {
loading: true;
error?: Error | undefined;
value?: T;
} | {
loading: false;
error: Error;
value?: undefined;
} | {
loading: false;
error?: undefined;
value: T;
};
type StateFromFunctionReturningPromise = UseAsyncState>>;
export type UseAsyncFnReturn = [StateFromFunctionReturningPromise, T];
/**
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useAsyncFn.ts)
*/
export declare let useAsyncFn: (fn: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise) => UseAsyncFnReturn;
export default useAsyncFn;