koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
21 lines (20 loc) • 468 B
JavaScript
"use client";
import { useRef as f, useEffect as c } from "react";
const i = ({ callback: u, interval: t, condition: n = !0 }) => {
const e = f();
c(() => {
e.current = u;
}, [u]), c(() => {
let r;
return t !== null && n && (r = setInterval(() => {
var s;
(s = e.current) == null || s.call(e);
}, t)), () => {
r && clearInterval(r);
};
}, [n, t]);
};
export {
i as useInterval
};
//# sourceMappingURL=useInterval.js.map