useInterval

Run a function on an interval that you can start and stop.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

A counter that ticks every second until you stop it.

APIs

useInterval

const useInterval = (
  fn: () => void,
  interval: number,
  options?: { autoInvoke?: boolean },
) => {
  start: () => void
  stop: () => void
  toggle: () => void
  active: boolean
}
Edit this page on GitHub