@thibault.sh/hooks
Version:
A comprehensive collection of React hooks for browser storage, UI interactions, and more
2 lines • 477 B
JavaScript
var react=require('react');function z(e){let[s,i]=react.useState({width:0,height:0});return react.useEffect(()=>{if(!e.current)return;let t=e.current,n=new ResizeObserver(r=>{if(!r[0])return;let{width:c,height:h}=r[0].contentRect;i({width:c,height:h});});return n.observe(t),i({width:t.offsetWidth,height:t.offsetHeight}),()=>{n.disconnect();}},[e]),s}exports.useElementSize=z;//# sourceMappingURL=useElementSize.cjs.map
//# sourceMappingURL=useElementSize.cjs.map
;