function MeasureExample() { const [rect, ref] = useClientRect(); return (

Hello, world

{rect !== null &&

The above header is {Math.round(rect.width)}px wide

} );}function useClientRect() { const [rect, setRect] = React.useState(null); const ref = React.useCallback(node => { if (node !== null) { setRect(node.getBoundingClientRect()); } }, []); return [rect, ref];}