Overview
onUpdate(fn) registers a callback on the host's onEachUpdate path. It runs synchronously after every render flush, including the first — before the browser paints.
If fn returns a function, that cleanup runs before the next onUpdate invocation and on unmount.
Unlike onPaint (double rAF after paint), onUpdate is immediate flush timing — good for syncing imperative libraries, not for layout measurement that needs painted geometry.
onUpdate vs onPaint vs onDOMReady
|
API
|
Timing
|
Notes
|
|---|---|---|
onUpdate
| Sync after flush | Before paint. Optional cleanup between calls. |
onDOMReady
| Microtask after render | DOM in host; every render. |
onPaint
| Double rAF after paint | Prefer for getBoundingClientRect. |
onUpdate after each flush
Counts render flushes as you type. Runs sync after each update — before paint.