@patreon/studio
Version:
Patreon Studio Design System
24 lines (23 loc) • 850 B
TypeScript
/**
* Use this hook to schedule a dynamic callback. The callback can be updated
* without affecting the timer. Additionally, if the delay or any other passed
* dependencies are shallowly mutated, the timer is restarted.
*
* For a detailed explanation of how this works, see Dan Abramov’s
* [article](https://overreacted.io/making-setinterval-declarative-with-react-hooks/).
*/
export declare function useTimeout(
/**
* Function to call when delay elapses. Can be mutated on subsequent render
* calls without affecting the timeout.
*/
callback: () => void,
/**
* Timeout delay, in milliseconds. If mutated, the timeout is restarted. If set
* to null, the existing timeout is canceled.
*/
delay: number | null,
/**
* If any of the dependencies in this array are mutated, the timeout is restarted.
*/
dependencies?: unknown[]): void;