Skip to content

[Fiber] Don't disappear Layout Effects when hydrating <Activity mode="hidden">#36613

Open
eps1lon wants to merge 1 commit into
facebook:mainfrom
eps1lon:sebbie/fiber-disappear-hidden-activity-hydration
Open

[Fiber] Don't disappear Layout Effects when hydrating <Activity mode="hidden">#36613
eps1lon wants to merge 1 commit into
facebook:mainfrom
eps1lon:sebbie/fiber-disappear-hidden-activity-hydration

Conversation

@eps1lon
Copy link
Copy Markdown
Collaborator

@eps1lon eps1lon commented Jun 3, 2026

We use fiber.memoizedState === null for to determine if the Offscreen Fiber is hidden. That state was initialized for hidden Offscreen everywhere except when hydrating hidden Offscreen when we bail out.

This lead to attempting to disappear Layout Effects. This works just fine now since there are no destroy functions registered just yet. So this is mostly for correctness. Perf concerns are negligible since the hidden Offscreen in Activity wouldn't have any child Fibers.

I only noticed this when trying to use offscreenSubtreeWasHidden in #34983. When hydrating <Activity mode="hidden">, we entered recursivelyTraverseDisappearLayoutEffects in

if (isHidden) {
// Only trigger disappear layout effects if:
// - This is an update, not first mount.
// - This Offscreen was not hidden before.
// - Ancestor Offscreen was not hidden in previous commit or in this commit
if (
isUpdate &&
!wasHidden &&
!offscreenSubtreeIsHidden &&
!offscreenSubtreeWasHidden
) {
if (
disableLegacyMode ||
(finishedWork.mode & ConcurrentMode) !== NoMode
) {
// Disappear the layout effects of all the children
recursivelyTraverseDisappearLayoutEffects(finishedWork);

@meta-cla meta-cla Bot added the CLA Signed label Jun 3, 2026
@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Jun 3, 2026
@react-sizebot
Copy link
Copy Markdown

Comparing: 63e95c2...7b22afd

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.01% 614.26 kB 614.33 kB = 108.57 kB 108.57 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.01% 680.19 kB 680.26 kB = 119.51 kB 119.52 kB
facebook-www/ReactDOM-prod.classic.js +0.01% 700.61 kB 700.68 kB = 123.09 kB 123.10 kB
facebook-www/ReactDOM-prod.modern.js +0.01% 690.93 kB 691.00 kB = 121.48 kB 121.48 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 7b22afd

@eps1lon eps1lon marked this pull request as ready for review June 3, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants