import * as React from 'react'; export type useAsyncStatus = 'idle' | 'pending' | 'success' | 'error'; /** * Wraps an (async) function and provides value, status and error states. * * Compares the `immediate` array using [use-deep-compare-effect](https://github.com/kentcdodds/use-deep-compare-effect) such that it does not have to be memoized. * * **Usage:** * ```typescript * // Somewhere outside * async function fetchData(id: number): Promise { * return fetch(...); * } * * // In the component * ... * const {status, error, execute: wrappedFetchData} = useAsync(fetchData); * // Or with single, but immediate execution * const {status, error, execute: wrappedFetchData} = useAsync(fetchData, [123]); * ... * wrappedFetchData(123) * ``` * * @param asyncFunction Async function to be wrapped. * @param params Null if function should not be triggered immediately, or the initial parameter array if immediate. */ export declare const useAsync: any, E = Error, T = Awaited>>(asyncFunction: F, params?: Parameters | null, options?: { /** * Comparison strategy for the params or deps parameter * @default 'deep' */ comparison?: "deep" | "shallow"; /** * Use these as deps instead of the params to trigger the async function */ deps?: React.DependencyList; }) => { execute: (...args: Parameters) => Promise; status: useAsyncStatus; value: T; error: E; args: Parameters; }; //# sourceMappingURL=useAsync.d.ts.map