Overview
onResize attaches a ResizeObserver to the host element (or an optional target) and disconnects on unmount.
onScroll listens on a target (default window). onWindowScroll uses capture so nested scroll containers are visible. onWindowResize is the window resize event.
Resize & scroll APIs
|
API
|
Target
|
Notes
|
|---|---|---|
onResize(fn, target?)
| Host / element | ResizeObserver; default target is the component host. |
onWindowResize(fn)
| window | Viewport resize — not element size. |
onScroll(fn, target?)
| window / element | Passive scroll listener; optional target. |
onWindowScroll(fn)
| window (capture) | Capture required because scroll does not bubble. |
onResize — element size tracker
onResize attaches a ResizeObserver to the component's root element. The observer is automatically disconnected when the component unmounts. Try resizing the preview pane to see the values update.