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.

25 lines (21 loc) 561 B
'use strict'; var react = require('react'); function useInterval(callback, delay) { const latestCallback = react.useRef(callback); react.useEffect(() => { latestCallback.current = callback; }, [callback]); react.useEffect(() => { if (!delay && delay !== 0) { return; } const id = setInterval(() => { if (latestCallback.current() === false) { clearInterval(id); } }, delay); return () => clearInterval(id); }, [delay]); } exports.useInterval = useInterval; //# sourceMappingURL=use-interval.cjs.map