useTimeout()
The
useTimeout() hook is a declarative wrapper around setTimeout. It handles setting up and clearing the timer automatically, and allows you to pause or clear the timeout by passing null as the delay.Import
typescript
Usage
Click Start to trigger an action after 3 seconds.
Click Cancel (or pass null) to abort the timeout.
😴
System Idle
Component.tsx
API
Arguments
callback– () => void The function to be executed when the timer expires.delay– number | null The time in milliseconds to wait. Passnullto stop/cancel the timer.
Returns
This hook returns
void.