UNPKG

565 BTypeScriptView Raw
1type Updater<T> = T | ((prevValue: T) => T);
2export type SetState<T> = (nextValue: Updater<T>,
3/**
4 * Will not update state when destroyed.
5 * Developer should make sure this is safe to ignore.
6 */
7ignoreDestroy?: boolean) => void;
8/**
9 * Same as React.useState but `setState` accept `ignoreDestroy` param to not to setState after destroyed.
10 * We do not make this auto is to avoid real memory leak.
11 * Developer should confirm it's safe to ignore themselves.
12 */
13export default function useSafeState<T>(defaultValue?: T | (() => T)): [T, SetState<T>];
14export {};