import { type DependencyList } from 'react'; /** * Async state */ export type AsyncState = { loading: boolean; error: Error | null; value: T | null; }; /** * Hook that executes an async function and tracks its state * * @template T - The return type of the async function * @param asyncFn - Async function to execute * @param deps - Dependency array (default: []) * @returns Async state object * * @example * ```tsx * const Component = () => { * const { loading, error, value } = useAsync(async () => { * const response = await fetch('/api/data'); * return response.json(); * }); * * if (loading) return
Loading...
; * if (error) return
Error: {error.message}
; * return
{JSON.stringify(value)}
; * }; * ``` */ export declare function useAsync(asyncFunction: () => Promise, deps?: DependencyList): AsyncState; //# sourceMappingURL=useAsync.d.ts.map