Uh oh!
There was an error while loading. Please reload this page.
[Fiber] Double invoke Effects in Strict Mode during Hydration - #35961
Merged
Conversation
Comparing: 23fcd7c...7bf5644 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
eps1lonforce-pushed
the
sebbie/se-hydration
branch
3 times, most recently
from
March 5, 2026 08:53
be46b22 to
8975211Compareeps1lon
marked this pull request as ready for review
March 5, 2026 08:59
acdlite
approved these changes
Apr 16, 2026
eps1lonforce-pushed
the
sebbie/se-hydration
branch
from
April 17, 2026 16:02
8975211 to
7bf5644CompareUh oh!
There was an error while loading. Please reload this page.
eps1lon pushed a commit
to vercel/next.js
that referenced
this pull request
Apr 20, 2026
[diff react/react@fef12a01...da9325b5](react/react@fef12a0...da9325b) <details> <summary>React upstream changes</summary> - react/react#35962 - react/react#35961 - react/react#36277 - react/react#36297 - react/react#36292 - react/react#36291 - react/react#36196 - react/react#36246 - react/react#36287 - react/react#36285 - react/react#36274 - react/react#36266 - react/react#36253 </details>
petehunt added a commit
to petehunt/react
that referenced
this pull request
Jul 24, 2026
…-invoke StrictMode's dev-only double invoke of effects (doubleInvokeEffectsOnFiber) runs disappearLayoutEffects + reappearLayoutEffects on a fiber that never actually leaves the tree. For HostSingletons (<html>/<head>/<body>) those paths call commitHostSingletonRelease/commitHostSingletonAcquisition, which destructively remove every attribute from the live DOM node and re-apply only React's props. Since react#35961 marks the hydrated HostRoot with PlacementDEV, the root subtree is now double-invoked on initial hydration, so the root <html> singleton gets released+re-acquired right after hydration. This wipes any attribute an inline script set before hydration (e.g. the no-flash-of-incorrect-theme pattern that seeds a class on <html> from localStorage). It is dev + StrictMode only; production is unaffected. The double invoke is meant to exercise effects and refs, not to re-mount host singletons (acquisition is a placement/DOM concern). Guard the singleton release/acquire with a new isRunningDoubleInvokeEffects flag set around the simulation, so the live singleton's attributes are preserved. Ref attach/detach still double-invokes via the HostComponent fallthrough.
m-kawafuji pushed a commit
to m-kawafuji/next.js
that referenced
this pull request
Aug 8, 2026
…#92945) [diff react/react@fef12a01...da9325b5](react/react@fef12a0...da9325b) <details> <summary>React upstream changes</summary> - react/react#35962 - react/react#35961 - react/react#36277 - react/react#36297 - react/react#36292 - react/react#36291 - react/react#36196 - react/react#36246 - react/react#36287 - react/react#36285 - react/react#36274 - react/react#36266 - react/react#36253 </details>
This was referenced Aug 21, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Also reported in vercel/next.js#66210
Not double invoking during Hydration was on oversight. Double invoking during Hydration ensures parity between
hydrateRootandcreateRoot.Double invoking an Effect is tracked with
PlacementDEV. This was always used together withPlacement. However, during hydration we don't track side-effects i.e. set noPlacementflag causing no double invocation of Effects in Strict Mode.Now we set
PlacementDEVwhen we set theHydrationflag to double invoke Effects in Strict Mode when we hydrated which is conceptually like a Placement during client-render.How did you test this change?