Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fiber] Disable comments as containers in OSS #32250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gnoff
Copy link
Collaborator

@gnoff gnoff commented Jan 28, 2025

stacked on #32224

3 years ago we partially disabled comment nodes as valid containers. Some unflagged support was left in due to legacy APIs like unmountComponentAtNode and unstable_renderSubtreeIntoContainer but these were since removed in React 19. This update flags the remaining uses of comments as containers.

@gnoff gnoff requested a review from sebmarkbage January 28, 2025 18:15
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jan 28, 2025
@react-sizebot
Copy link

react-sizebot commented Jan 28, 2025

Comparing: c492f97...d270d18

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.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.09% 515.10 kB 515.58 kB +0.21% 91.81 kB 92.00 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.09% 558.79 kB 559.27 kB +0.16% 99.13 kB 99.29 kB
facebook-www/ReactDOM-prod.classic.js +0.17% 597.07 kB 598.10 kB +0.27% 104.95 kB 105.24 kB
facebook-www/ReactDOM-prod.modern.js +0.18% 587.50 kB 588.53 kB +0.27% 103.41 kB 103.69 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.js +0.79% 228.10 kB 229.90 kB +0.54% 40.90 kB 41.12 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.js +0.79% 228.17 kB 229.98 kB +0.54% 40.93 kB 41.15 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js +0.78% 229.85 kB 231.63 kB +0.52% 41.89 kB 42.10 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js +0.78% 229.92 kB 231.71 kB +0.52% 41.91 kB 42.13 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.js +0.77% 233.30 kB 235.10 kB +0.54% 42.86 kB 43.09 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.js +0.77% 233.38 kB 235.18 kB +0.54% 42.89 kB 43.12 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.js +0.71% 254.27 kB 256.07 kB +0.46% 43.96 kB 44.16 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +0.71% 213.71 kB 215.23 kB +0.46% 39.45 kB 39.64 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +0.71% 213.79 kB 215.30 kB +0.46% 39.48 kB 39.66 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +0.70% 221.38 kB 222.93 kB +0.41% 40.93 kB 41.09 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js +0.70% 256.09 kB 257.88 kB +0.44% 45.11 kB 45.31 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.js +0.69% 260.04 kB 261.84 kB +0.46% 46.03 kB 46.24 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.67% 209.41 kB 210.82 kB +0.43% 38.23 kB 38.40 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.67% 209.44 kB 210.84 kB +0.43% 38.26 kB 38.42 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.js +0.66% 213.93 kB 215.33 kB +0.44% 40.00 kB 40.17 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.js +0.66% 213.95 kB 215.36 kB +0.43% 40.03 kB 40.20 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.65% 232.87 kB 234.39 kB +0.42% 41.86 kB 42.04 kB
facebook-www/ReactDOMServer-prod.modern.js +0.65% 217.07 kB 218.47 kB +0.44% 39.30 kB 39.47 kB
facebook-www/ReactDOMServer-prod.classic.js +0.64% 219.75 kB 221.16 kB +0.42% 39.63 kB 39.80 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.62% 226.97 kB 228.38 kB +0.43% 40.50 kB 40.67 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.61% 232.05 kB 233.46 kB +0.41% 42.41 kB 42.58 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js +0.56% 316.53 kB 318.31 kB +0.36% 61.61 kB 61.83 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js +0.56% 316.60 kB 318.38 kB +0.36% 61.63 kB 61.86 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js +0.56% 367.24 kB 369.29 kB +0.35% 66.19 kB 66.42 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js +0.56% 367.31 kB 369.36 kB +0.35% 66.24 kB 66.47 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js +0.56% 370.69 kB 372.76 kB +0.33% 66.83 kB 67.05 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js +0.56% 370.77 kB 372.84 kB +0.33% 66.88 kB 67.10 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js +0.56% 371.46 kB 373.53 kB +0.33% 66.99 kB 67.21 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js +0.56% 371.54 kB 373.61 kB +0.33% 67.05 kB 67.27 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.55% 363.39 kB 365.37 kB +0.35% 65.68 kB 65.91 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.52% 343.60 kB 345.37 kB +0.34% 65.21 kB 65.44 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js +0.52% 355.25 kB 357.08 kB +0.37% 64.66 kB 64.89 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.52% 355.25 kB 357.09 kB +0.37% 64.66 kB 64.89 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js +0.52% 355.27 kB 357.11 kB +0.36% 64.68 kB 64.92 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.52% 355.28 kB 357.11 kB +0.36% 64.68 kB 64.92 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +0.51% 405.52 kB 407.57 kB +0.32% 70.56 kB 70.78 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +0.50% 409.57 kB 411.63 kB +0.31% 71.11 kB 71.33 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js +0.50% 410.35 kB 412.42 kB +0.35% 71.27 kB 71.51 kB
facebook-www/ReactDOMServer-dev.modern.js +0.49% 371.83 kB 373.67 kB +0.36% 66.94 kB 67.18 kB
facebook-www/ReactDOMServer-dev.classic.js +0.48% 378.66 kB 380.49 kB +0.37% 67.95 kB 68.20 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +0.48% 384.72 kB 386.56 kB +0.37% 68.24 kB 68.49 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.48% 384.72 kB 386.56 kB +0.36% 68.24 kB 68.49 kB
oss-experimental/react-markup/cjs/react-markup.production.js +0.42% 215.24 kB 216.14 kB +0.19% 39.74 kB 39.82 kB
oss-experimental/react-markup/cjs/react-markup.development.js +0.31% 356.28 kB 357.37 kB +0.16% 63.97 kB 64.07 kB
oss-experimental/react-markup/cjs/react-markup.react-server.production.js +0.29% 314.98 kB 315.88 kB +0.13% 58.89 kB 58.97 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js +0.21% 529.48 kB 530.56 kB +0.11% 94.93 kB 95.04 kB

Generated by 🚫 dangerJS against 6c7a725

gnoff added 2 commits January 28, 2025 22:43
stacked on facebook#32163

This continues the work of making Suspense workable anywhere in a react-dom tree. See the prior PRs for how we handle server rendering and client rendering. In this change we update the hydration implementation to be able to locate expected nodes. In particular this means hydration understands now that the default hydration context is the document body when the container is above the body.

One case that is unique to hydration is clearing Suspense boundaries. When hydration fails or when the server instructs the client to recover an errored boundary it's possible that the html, head, and body tags in the initial document were written from a fallback or a different primary content on the server and need to be replaced by the client render. However these tags (and in the case of head, their content) won't be inside the comment nodes that identify the bounds of the Suspense boundary. And when client rendering you may not even render the same singletons that were server rendered. So when server rendering a boudnary which contributes to the preamble (the html, head, and body tag openings plus the head contents) we emit a special marker comment just before closing the boundary out. This marker encodes which parts of the preamble this boundary owned. If we need to clear the suspense boundary on the client we read this marker and use it to reset the appropriate singleton state.
3 years ago we partially disabled comment nodes as valid containers. Some unflagged support was left in due to legacy APIs like `unmountComponentAtNode` and `unstable_renderSubtreeIntoContainer` but these were since removed in React 19. This update flags the remaining uses of comments as containers.
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.

3 participants