Overview
onAllMount(fn) registers a callback that runs once after the current component and every descendant have finished their initial mount. Internally it uses the scheduler's idle queue (onceIdle), so it fires when the subtree is fully registered.
Unlike onMount, which runs as soon as this component's DOM is ready (children may still be mounting), onAllMount waits for the whole tree. That makes it the right hook for analytics “time to interactive”, layout passes that measure child nodes, or enabling features that depend on child readiness.
If fn returns a function, that cleanup is registered and runs on unmount — same pattern as sync onMount.
onMount vs onAllMount
|
API
|
Waits for children?
|
Use when
|
|---|---|---|
onMount(fn)
| No | This component's DOM is ready. Self-contained setup, timers, focus. |
onAllMount(fn)
| Yes — entire subtree | Analytics, layout that needs child DOM, feature gates after hydration. |
onAllMount — wait for all children
The Dashboard's onAllMount callback fires only after Widget A, B, and C have all completed their own onMount. This guarantees the entire subtree is hydrated before the callback runs.