@guruhotel/aura-hooks
Version:
🪝 Hooks library designed by the Guruhotel team for Aura UI
1 lines • 388 B
JavaScript
exports.__esModule=!0,exports.useInterval=function(r,t){const[n,u]=(0,e.useState)(!1),c=(0,e.useRef)(),s=(0,e.useRef)();(0,e.useEffect)((()=>{s.current=r}),[r]);const o=()=>{u((e=>(e||c.current||(c.current=window.setInterval(s.current,t)),!0)))},a=()=>{u(!1),window.clearInterval(c.current),c.current=void 0};return{start:o,stop:a,toggle:()=>{n?a():o()},active:n}};var e=require("react");