useUniverse
useUniverse names the component this render draws into — for the component
a <ui> hosts, the interface’s own outermost box; for a nested one, the
container it was placed in.
useUniverse(): RefReference
Section titled “Reference”useUniverse()
Section titled “useUniverse()”const DropList = (): Component => { const universe = useUniverse(); const list = useRef(); const content: Int = DROPS.length * ROW_H;
return ( <layer w="fill" h="fill"> <SunkenBox> <layer ref={list} x={2} y={2} w={{ fill: 22 }} h={{ fill: 4 }} scrollHeight={content > universe.height ? content : 0}>Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”A Ref to the box. Its geometry — width, height, x, y — reads like
any ref’s.
Caveats
Section titled “Caveats”- It is read once. To follow a resize, use
useOnResize(universe), oronResizeon the element. - Inside a component only (
TS2E215). - Reach for it only when a keyword cannot say what you mean.
const universe = useUniverse(); // no component hereDeciding whether to scroll
Section titled “Deciding whether to scroll” scrollHeight={content > universe.height ? content : 0}>Sizing from the box, and following it
Section titled “Sizing from the box, and following it” const universe = useUniverse(); useOnResize(universe);
const track: Int = universe.width - 8;Troubleshooting
Section titled “Troubleshooting”The size is wrong after the window is resized
Section titled “The size is wrong after the window is resized”The read was taken once, when the component built. Add
useOnResize(universe) so the component builds again when the window’s resize
changes its box.