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

NameTypeDescriptionDefault
callback() => voidFunction to run after delay.-
delaynumber | nullDelay in milliseconds; pass null to cancel the scheduled timeout.-

Returns

NameDescription
voidNo 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.
Saha UI - The Modern React Component Library