useInterval

Utility

A React hook that creates a setInterval with automatic cleanup and the ability to pause/resume by passing null as the delay.

Installation

npm install @thibault.sh/hooks

API Reference

Signature

function useInterval(callback: () => void, delay: number | null): void

Parameters

NameTypeDescriptionDefault
callback
() => void
The function to execute on each interval tick.-
delay
number | null
The delay in milliseconds between executions, or null to pause the interval.-

Returns

void

This hook does not return anything.

useInterval Hook - React Interval Management