@mirawision/reactive-hooks
Version:
A comprehensive collection of 50+ React hooks for state management, UI interactions, device APIs, async operations, drag & drop, audio/speech, and more. Full TypeScript support with SSR safety.
15 lines (14 loc) • 558 B
TypeScript
export interface AsyncState<T> {
run: (...args: any[]) => Promise<T>;
data: T | null;
error: any;
loading: boolean;
reset: () => void;
}
/**
* A hook that wraps an async function with state management.
* @param fn The async function to wrap
* @param deps Optional dependencies array that will trigger function reference update
* @returns AsyncState object containing run function, data, error, loading state, and reset function
*/
export declare function useAsync<T>(fn: (...args: any[]) => Promise<T>, deps?: any[]): AsyncState<T>;