useRefresh()function
useRefresh(interval: number): void
| Param | Type | |
|---|---|---|
interval | number | The refresh period in milliseconds. required |
Re-render a component automatically on a fixed interval.
- Holds the current time in state and updates it every
intervalmilliseconds, forcing a refresh. - Clears the timer on unmount or when
intervalchanges.
Examples
useRefresh(1000); // re-renders once per second, e.g. for a live clock