useTimer
A hook for managing timers with start, stop, and restart functionality
Preview
Basic Timer
Timer with Controls
Completed count: 0
Installation
Usage
API Reference
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
delay | number | - | The timer duration in milliseconds |
onTimeout | () => void | - | Callback function called when timer completes |
enabled | boolean | true | Whether the timer is enabled |
Return Value
Returns an object with the following properties:
| Property | Type | Description |
|---|---|---|
isActive | boolean | Whether the timer is currently running |
remainingTime | number | Remaining time in milliseconds |
start | () => void | Starts the timer |
stop | () => void | Stops the timer |
restart | (activate?: boolean) => void | Restarts the timer. If activate is true, starts even if not currently active |