Loading homepage
Build a React hook that runs a callback repeatedly at a configurable interval, supports pausing with null, and always calls the latest callback without restarting a running interval.
The JavaScript and TypeScript variants share the same contract. Tests render real React components and exercise updates and lifecycle cleanup.
Input: useInterval(() => setCount(count => count + 1), 1000) Output: Increments count approximately once per second while mounted.
Input: Rerender with delay = null Output: Stops future ticks until resumed.
Input: Rerender with a new callback and the same delay Output: The next tick uses the new callback without creating a new interval.
Examples describe the current return value after the corresponding React render or event.