useLayout
function useLayout(nodeRef?): LayoutRect;Subscribe to the computed layout of a node.
Returns a LayoutRect that updates whenever the layout engine recalculates positions (e.g. on resize or content change).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
nodeRef? | { current: GlyphNode | null; } | React ref pointing to the target GlyphNode. |
nodeRef.current? | GlyphNode | null | - |
Returns
Section titled “Returns”Current layout rectangle (outer + inner bounds).
Example
Section titled “Example”const boxRef = useRef<GlyphNode>(null);const layout = useLayout(boxRef);
<Box ref={boxRef}> <Text>Width: {layout.innerWidth} Height: {layout.innerHeight}</Text></Box>