Read the most recent computed layout (left / top / width / height) of a
<Box> referenced by ref. Returns null until the ref attaches and
the first layout pass completes.
The hook tracks two re-render triggers so consumers see fresh values:
SIGWINCH via useStdout() — terminal resize re-renders the
consumer because columns / rows are part of the dep graph.
Post-commit force via a useEffect that bumps an internal
version after every commit. Without this, a layout change driven
purely by sibling state (which doesn't re-render the consumer)
would leave the consumer reading stale metrics.
Consumers should treat the return value as advisory: it reflects the
layout AT THE TIME of the consumer's render, which is one commit
behind the actual frame for the very first mount (null until the
post-commit effect bumps).
Read the most recent computed layout (left / top / width / height) of a
<Box>referenced byref. Returnsnulluntil the ref attaches and the first layout pass completes.The hook tracks two re-render triggers so consumers see fresh values:
useStdout()— terminal resize re-renders the consumer becausecolumns/rowsare part of the dep graph.useEffectthat bumps an internal version after every commit. Without this, a layout change driven purely by sibling state (which doesn't re-render the consumer) would leave the consumer reading stale metrics.Consumers should treat the return value as advisory: it reflects the layout AT THE TIME of the consumer's render, which is one commit behind the actual frame for the very first mount (
nulluntil the post-commit effect bumps).