@ohm-vision/react-async
Version:
Extentions to React to support asynchronous calls
14 lines (13 loc) • 680 B
TypeScript
import { DependencyList, EffectCallback } from "react";
/**
* Wraps and creates a memo-like result using the `useState`
*
* `useMemoAsync` will only recompute the memoized value when one of the `deps` has changed
*
* **Note**: Just like with the native `useMemo`, this will return the previous value until the calculation has changed
* @param factory Asynchronous function to call
* @param deps Dependency List
* @param destructor Destructor
* @returns `TResult | undefined`
*/
export declare function useMemoAsync<TResult>(factory: (abortSignal: AbortController) => Promise<TResult>, deps: DependencyList, destructor?: ReturnType<EffectCallback>): TResult | undefined;