Show timer in bubble if timed activity exists

This commit is contained in:
manubo
2019-09-19 17:33:41 +02:00
parent 6577ab2a1a
commit 1403875207
7 changed files with 87 additions and 20 deletions

View File

@@ -0,0 +1,18 @@
import { useEffect, useRef } from "react"
export function useInterval(callback, delay) {
const savedCallback = useRef()
useEffect(() => {
savedCallback.current = callback
})
useEffect(() => {
function tick() {
savedCallback.current()
}
let id = setInterval(tick, delay)
return () => clearInterval(id)
}, [delay])
}