Run code at specified time intervals. Code will continue to run after every interval lapse until the interval is cleared or the window is closed.

Example

import { useInterval } from 'vev';
import { useState } from 'react';
export default function() {
const [count, setCount] = useState<number>(0);
// Increase counter every second
useInterval(() => setCount(count + 1), 1000);
return <h1>{count}</h1>;
}

Did this answer your question?