function MeasuredBox() { const boxRef = useRef(null); const [dimensions, setDimensions] = useState({ width: 0, height: 0 }); useEffect(() => { if (boxRef.current) { const { width, height } = boxRef.current.getBoundingClientRect(); setDimensions({ width, height }); } }, []); return (
Contenu de la boƮte

Dimensions : {dimensions.width} x {dimensions.height}

); }