@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
17 lines (16 loc) • 680 B
TypeScript
/**
* MSKCC DSM 2021, 2023
*/
import { SetStateAction } from 'react';
/**
* `useDelayedState` mirrors `useState` but also allows you to add a delay to
* when your state updates. You can provide a second argument to `setState`,
* `delayMs`, which will be the time in milliseconds after which the state is
* updated.
*
* This hook will clean up pending timers in `useEffect` and will cancel any
* pending timers when a `setState` is called before the state is updated from
* a previous call
*/
export type DispatchWithDelay<A> = (value: A, delayMS?: number) => void;
export declare function useDelayedState<S>(initialState: S): [S, DispatchWithDelay<SetStateAction<S>>];