UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

23 lines (20 loc) 529 B
import { useRef, useEffect } from 'react'; function useInterval(callback, delay) { const latestCallback = useRef(callback); useEffect(() => { latestCallback.current = callback; }, [callback]); useEffect(() => { if (!delay && delay !== 0) { return; } const id = setInterval(() => { if (latestCallback.current() === false) { clearInterval(id); } }, delay); return () => clearInterval(id); }, [delay]); } export { useInterval }; //# sourceMappingURL=use-interval.js.map