UNPKG

@thibault.sh/hooks

Version:

A comprehensive collection of React hooks for browser storage, UI interactions, and more

2 lines 467 B
import {useState,useEffect}from'react';function z(e){let[s,i]=useState({width:0,height:0});return 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}export{z as useElementSize};//# sourceMappingURL=useElementSize.mjs.map //# sourceMappingURL=useElementSize.mjs.map