packages
useInterval

useInterval

Executes a callback on an interval

useInterval(callback, interval)

Usage

const Component = () => {
  const [state, setState] = React.useState(0);
 
  useInterval(() => setState((prev) => prev + 1), 1000);
 
  return <p>{state}</p>;
};

Arguments


NameTypeRequired?
callback() => void
inervalnumber

Returns

Nothin 🤪