Utility
useTimeout
Declarative setTimeout with automatic cleanup and reset functionality.
import { useTimeout } from "saha-ui"Uses
Declarative timeout hook that runs a callback after a specified delay and cleans up automatically.
Props
| Name | Type | Description | Default |
|---|---|---|---|
| callback | () => void | Function to run after delay. | - |
| delay | number | null | Delay in milliseconds; pass null to cancel the scheduled timeout. | - |
Returns
| Name | Description |
|---|---|
| void | No return; schedules the callback as a side effect according to the delay. |
Example
useTimeout(() => console.log('done'), 3000);Notes
Keeps the latest callback in a ref so the timeout always calls the most recent function.