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