useState.d.ts 694 B

1234567891011121314151617
  1. /**
  2. * copy from https://github.com/react-component/util/blob/9d5cb8946da29e690bead78b2c251da6f7cbd0eb/src/hooks/useState.ts
  3. */
  4. type Updater<T> = T | ((prevValue: T) => T);
  5. export type SetState<T> = (nextValue: Updater<T>,
  6. /**
  7. * Will not update state when destroyed.
  8. * Developer should make sure this is safe to ignore.
  9. */
  10. ignoreDestroy?: boolean) => void;
  11. /**
  12. * Same as React.useState but `setState` accept `ignoreDestroy` param to not to setState after destroyed.
  13. * We do not make this auto is to avoid real memory leak.
  14. * Developer should confirm it's safe to ignore themselves.
  15. */
  16. export declare function useSafeState<T>(defaultValue?: T | (() => T)): [T, SetState<T>];
  17. export {};