Skip to main content

useInterval

This hook makes it easy to use window.setInterval.

// Please enter a number or IntervalOptions
type IntervalOptions =
| number
| {
// Specifies the delay between each Effect.
delay: number | null;
// If it is specified as false, the Effect will run immediately.
trailing?: boolean;
// If it is specified as false, the Effect will not run.
enabled?: boolean;
};

Example

useInterval(updateServerTime, { delay: interval });