UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

21 lines (17 loc) 539 B
"use strict"; exports.__esModule = true; exports.default = void 0; var _react = require("react"); function useInterval(callback, delay) { const savedCallback = (0, _react.useRef)(callback); (0, _react.useEffect)(() => { savedCallback.current = callback; }, [callback]); (0, _react.useEffect)(() => { if (!delay && delay !== 0) return undefined; const id = setInterval(() => savedCallback.current(), delay); return () => clearInterval(id); }, [delay]); } var _default = useInterval; exports.default = _default;