useState.d.ts 565 B

1234567891011121314
  1. type Updater<T> = T | ((prevValue: T) => T);
  2. export 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. */
  7. ignoreDestroy?: 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. */
  13. export default function useSafeState<T>(defaultValue?: T | (() => T)): [T, SetState<T>];
  14. export {};