react-async-ui
Version:
Asynchronous React hooks to manage modal UI state
17 lines (16 loc) • 689 B
TypeScript
import { type AsyncModalState } from './AsyncModalState';
/**
* Manages the state of a modal UI element that can be invoked asynchronously
* using the returned `showModal` callback.
*
* @remarks
* The `TValue` and `TResult` type parameters indicate the type of the argument to
* `showModal` and the type of its return value, respectively. Both default to `void`,
* i.e., a modal that takes no arguments and returns no value upon completion.
*
* @returns Array with `state` and `showModal` elements
*/
export declare function useAsyncModalState<TValue = void, TResult = void>(): [
state: AsyncModalState<TValue, TResult>,
showModal: (value: TValue) => Promise<TResult>
];