You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
options.unmount ancestor walk makes whole-tree unmount O(hook components × depth) #5217
During a full unmount there is no such ancestor. unmount() clears _parentDom on the way down:
render(null, container)
unmount(App) App._parentDom = null
unmount(Wrapper) Wrapper._parentDom = null
unmount(Leaf) ← walk runs here, every ancestor already null
So the walk always reaches the root and yields null. Subtree unmounts are fine — the parent above the removed root is still mounted, so it stops on step one.
Benchmarks
Our destroyBackground suite splits on one thing: does the fixture use hooks? (full CodSpeed report on our PR, Simulation mode = instruction counts, not timing noise.)
benchmark
hooks
10.x → 11.0.0-rc.1
008-many-use-state
1000 components, one useState each
-6.04%
015-attrs-component
none
+5.44%
002-hello-reactLynx
none
+5.37%
012-attrs-compile
none
+5.34%
rc.1 made everything ~5% faster. Only the hook fixture regressed — matching where the walk sits, inside if (c && c.__hooks). Instrumenting it during a real page destroy: { calls: 1000, iters: 3000 }, i.e. 1000 components × 3 levels, exactly the tree depth.
Every component in a full unmount resolves to the same errorParent, so it could presumably be computed once per pass. We don't know why the parentVNode argument was dropped, so we're reporting rather than proposing a patch.
Mind checking whether #5218 resolves your issue sufficiently, I opted for an approach where we only ever look at this when we have effects containing cleanups which should reduce this in the general case
Activity
perf(hooks): resolve unmount error routing lazily
JoviDeCroock commentedon Aug 27, 2026
Mind checking whether #5218 resolves your issue sufficiently, I opted for an approach where we only ever look at this when we have effects containing cleanups which should reduce this in the general case
upupming commentedon Aug 27, 2026
@JoviDeCroock I have tested it locally, it works since the benchmark case has no effect cleanups, thanks!
Merge pull request #5218 from preactjs/JoviDeCroock/issue-5217
chore(react): bump the Preact fork to the latest upstream main
chore(react): bump the Preact fork to the latest upstream main (#3758)