stacker.news/components/use-interval.js

11 lines
223 B
JavaScript

import { useEffect } from 'react'
function useInterval (cb, ms, deps) {
return useEffect(() => {
const interval = setInterval(cb, ms)
return () => clearInterval(interval)
}, deps)
}
export default useInterval