@guruhotel/aura-hooks
Version:
🪝 Hooks library designed by the Guruhotel team for Aura UI
1 lines • 442 B
JavaScript
exports.__esModule=!0,exports.useDebouncedValue=function(r,u,t={leading:!1}){const[n,c]=(0,e.useState)(r),s=(0,e.useRef)(!1),o=(0,e.useRef)(void 0),i=(0,e.useRef)(!1),a=()=>window.clearTimeout(o.current);return(0,e.useEffect)((()=>{s.current&&(!i.current&&t.leading?(i.current=!0,c(r)):(a(),o.current=window.setTimeout((()=>{i.current=!1,c(r)}),u)))}),[r,t.leading,u]),(0,e.useEffect)((()=>(s.current=!0,a)),[]),[n,a]};var e=require("react");