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

Add Server Context deprecation warning #27424

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Sep 27, 2023

As agreed, we're removing Server Context. This was never official documented.

We've found that it's not that useful in practice. Often the better options are:

  • Read things off the url or global scope like params or cookies.
  • Use the module system for global dependency injection.
  • Use React.cache() to dedupe multiple things instead of computing once and passing down.

There are still legit use cases for Server Context but you have to be very careful not to pass any large data, so in generally we recommend against it anyway.

Yes, prop drilling is annoying but it's not impossible for the cases this is needed. I would personally always pick it over Server Context anyway.

Semantically, Server Context also blocks object deduping due to how it plays out with Server Components that can't be deduped. This is much more important feature.

Since it's already in canary along with the rest of RSC, we're adding a warning for a few versions before removing completely to help migration.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Sep 27, 2023
@react-sizebot
Copy link

react-sizebot commented Sep 27, 2023

Comparing: bff6be8...6b3290b

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.min.js = 167.45 kB 167.45 kB = 52.15 kB 52.15 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 176.11 kB 176.11 kB = 54.84 kB 54.84 kB
facebook-www/ReactDOM-prod.classic.js = 563.33 kB 563.33 kB = 99.28 kB 99.28 kB
facebook-www/ReactDOM-prod.modern.js = 547.06 kB 547.06 kB = 96.35 kB 96.35 kB
oss-stable-semver/react-client/cjs/react-client-flight.development.js +2.77% 51.20 kB 52.61 kB +3.31% 12.71 kB 13.13 kB
oss-stable/react-client/cjs/react-client-flight.development.js +2.77% 51.20 kB 52.61 kB +3.31% 12.71 kB 13.13 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.74% 51.61 kB 53.03 kB +3.38% 12.45 kB 12.87 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.74% 51.61 kB 53.03 kB +3.38% 12.45 kB 12.87 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.68% 51.45 kB 52.83 kB +3.34% 12.39 kB 12.80 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.68% 51.45 kB 52.83 kB +3.34% 12.39 kB 12.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.62% 54.11 kB 55.52 kB +3.21% 13.17 kB 13.59 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.62% 54.11 kB 55.52 kB +3.21% 13.17 kB 13.59 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.59% 57.58 kB 59.07 kB +3.15% 13.38 kB 13.80 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.59% 57.58 kB 59.07 kB +3.15% 13.38 kB 13.80 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.53% 56.06 kB 57.48 kB +3.08% 13.56 kB 13.98 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.53% 56.06 kB 57.48 kB +3.08% 13.56 kB 13.98 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +2.52% 56.24 kB 57.66 kB +3.01% 13.72 kB 14.13 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.50% 56.66 kB 58.08 kB +3.15% 13.44 kB 13.87 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.47% 57.35 kB 58.76 kB +3.02% 13.89 kB 14.30 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.47% 57.35 kB 58.76 kB +3.02% 13.89 kB 14.30 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.46% 39.29 kB 40.25 kB +3.39% 9.49 kB 9.81 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.46% 39.29 kB 40.25 kB +3.39% 9.49 kB 9.81 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.44% 56.50 kB 57.87 kB +3.11% 13.39 kB 13.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.42% 58.59 kB 60.00 kB +3.01% 14.28 kB 14.71 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.42% 58.59 kB 60.00 kB +3.01% 14.28 kB 14.71 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.39% 59.15 kB 60.57 kB +3.00% 14.16 kB 14.59 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.39% 59.31 kB 60.72 kB +3.02% 14.42 kB 14.85 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.39% 59.31 kB 60.72 kB +3.02% 14.42 kB 14.85 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.37% 62.93 kB 64.42 kB +2.94% 14.40 kB 14.83 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.32% 61.11 kB 62.53 kB +2.85% 14.57 kB 14.99 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.27% 62.39 kB 63.81 kB +2.78% 14.90 kB 15.32 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.23% 63.63 kB 65.05 kB +2.79% 15.29 kB 15.72 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.20% 64.36 kB 65.77 kB +2.76% 15.44 kB 15.87 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.18% 44.37 kB 45.34 kB +2.95% 10.49 kB 10.80 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +2.07% 65.02 kB 66.37 kB +2.67% 15.87 kB 16.30 kB
oss-stable/react-server/cjs/react-server-flight.development.js +2.07% 65.02 kB 66.37 kB +2.67% 15.87 kB 16.30 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.min.js +2.05% 9.99 kB 10.20 kB +2.04% 3.83 kB 3.91 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.min.js +2.05% 9.99 kB 10.20 kB +2.04% 3.83 kB 3.91 kB
oss-stable-semver/react-client/cjs/react-client-flight.production.min.js +2.04% 9.94 kB 10.15 kB +2.00% 3.84 kB 3.92 kB
oss-stable/react-client/cjs/react-client-flight.production.min.js +2.04% 9.94 kB 10.15 kB +2.00% 3.84 kB 3.92 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-client/cjs/react-client-flight.development.js +2.77% 51.20 kB 52.61 kB +3.31% 12.71 kB 13.13 kB
oss-stable/react-client/cjs/react-client-flight.development.js +2.77% 51.20 kB 52.61 kB +3.31% 12.71 kB 13.13 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.74% 51.61 kB 53.03 kB +3.38% 12.45 kB 12.87 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.74% 51.61 kB 53.03 kB +3.38% 12.45 kB 12.87 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.68% 51.45 kB 52.83 kB +3.34% 12.39 kB 12.80 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.68% 51.45 kB 52.83 kB +3.34% 12.39 kB 12.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.62% 54.11 kB 55.52 kB +3.21% 13.17 kB 13.59 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.62% 54.11 kB 55.52 kB +3.21% 13.17 kB 13.59 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.59% 57.58 kB 59.07 kB +3.15% 13.38 kB 13.80 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.59% 57.58 kB 59.07 kB +3.15% 13.38 kB 13.80 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.53% 56.06 kB 57.48 kB +3.08% 13.56 kB 13.98 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.53% 56.06 kB 57.48 kB +3.08% 13.56 kB 13.98 kB
oss-experimental/react-client/cjs/react-client-flight.development.js +2.52% 56.24 kB 57.66 kB +3.01% 13.72 kB 14.13 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.development.js +2.50% 56.66 kB 58.08 kB +3.15% 13.44 kB 13.87 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.47% 57.35 kB 58.76 kB +3.02% 13.89 kB 14.30 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.47% 57.35 kB 58.76 kB +3.02% 13.89 kB 14.30 kB
oss-stable-semver/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.46% 39.29 kB 40.25 kB +3.39% 9.49 kB 9.81 kB
oss-stable/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.46% 39.29 kB 40.25 kB +3.39% 9.49 kB 9.81 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.development.js +2.44% 56.50 kB 57.87 kB +3.11% 13.39 kB 13.80 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.42% 58.59 kB 60.00 kB +3.01% 14.28 kB 14.71 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.42% 58.59 kB 60.00 kB +3.01% 14.28 kB 14.71 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +2.39% 59.15 kB 60.57 kB +3.00% 14.16 kB 14.59 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.39% 59.31 kB 60.72 kB +3.02% 14.42 kB 14.85 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.39% 59.31 kB 60.72 kB +3.02% 14.42 kB 14.85 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.development.js +2.37% 62.93 kB 64.42 kB +2.94% 14.40 kB 14.83 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.development.js +2.32% 61.11 kB 62.53 kB +2.85% 14.57 kB 14.99 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2.27% 62.39 kB 63.81 kB +2.78% 14.90 kB 15.32 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +2.23% 63.63 kB 65.05 kB +2.79% 15.29 kB 15.72 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +2.20% 64.36 kB 65.77 kB +2.76% 15.44 kB 15.87 kB
oss-experimental/react-server-dom-esm/esm/react-server-dom-esm-client.browser.production.min.js +2.18% 44.37 kB 45.34 kB +2.95% 10.49 kB 10.80 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +2.07% 65.02 kB 66.37 kB +2.67% 15.87 kB 16.30 kB
oss-stable/react-server/cjs/react-server-flight.development.js +2.07% 65.02 kB 66.37 kB +2.67% 15.87 kB 16.30 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.min.js +2.05% 9.99 kB 10.20 kB +2.04% 3.83 kB 3.91 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.min.js +2.05% 9.99 kB 10.20 kB +2.04% 3.83 kB 3.91 kB
oss-stable-semver/react-client/cjs/react-client-flight.production.min.js +2.04% 9.94 kB 10.15 kB +2.00% 3.84 kB 3.92 kB
oss-stable/react-client/cjs/react-client-flight.production.min.js +2.04% 9.94 kB 10.15 kB +2.00% 3.84 kB 3.92 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +1.95% 69.21 kB 70.55 kB +2.62% 16.50 kB 16.93 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +1.91% 10.70 kB 10.90 kB +1.87% 4.12 kB 4.19 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +1.91% 10.70 kB 10.90 kB +1.87% 4.12 kB 4.19 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +1.85% 10.96 kB 11.17 kB +1.47% 4.22 kB 4.28 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +1.85% 10.96 kB 11.17 kB +1.47% 4.22 kB 4.28 kB
oss-experimental/react-client/cjs/react-client-flight.production.min.js +1.82% 11.13 kB 11.33 kB +1.84% 4.18 kB 4.25 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.browser.production.min.js +1.81% 11.30 kB 11.50 kB +1.67% 4.18 kB 4.25 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.min.js +1.78% 11.49 kB 11.70 kB +1.86% 4.31 kB 4.39 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.min.js +1.78% 11.49 kB 11.70 kB +1.86% 4.31 kB 4.39 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +1.72% 11.89 kB 12.10 kB +1.76% 4.48 kB 4.56 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +1.72% 11.89 kB 12.10 kB +1.76% 4.48 kB 4.56 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.min.js +1.69% 12.00 kB 12.20 kB +1.63% 4.47 kB 4.54 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +1.67% 12.22 kB 12.42 kB +1.65% 4.62 kB 4.69 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +1.67% 12.22 kB 12.42 kB +1.65% 4.62 kB 4.69 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-client.browser.production.min.js +1.66% 12.27 kB 12.47 kB +1.42% 4.57 kB 4.64 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +1.63% 12.48 kB 12.68 kB +1.72% 4.70 kB 4.78 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +1.63% 12.48 kB 12.68 kB +1.72% 4.70 kB 4.78 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-client.node.production.min.js +1.59% 12.81 kB 13.02 kB +1.52% 4.68 kB 4.75 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +1.54% 13.21 kB 13.42 kB +1.55% 4.85 kB 4.92 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.min.js +1.50% 13.54 kB 13.74 kB +1.44% 4.98 kB 5.06 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.min.js +1.47% 13.79 kB 13.99 kB +1.40% 5.07 kB 5.14 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.36% 99.04 kB 100.39 kB +1.77% 23.61 kB 24.02 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.36% 99.04 kB 100.39 kB +1.77% 23.61 kB 24.02 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.31% 102.77 kB 104.12 kB +1.66% 24.80 kB 25.21 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.31% 102.77 kB 104.12 kB +1.66% 24.80 kB 25.21 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +1.31% 108.67 kB 110.09 kB +1.51% 25.18 kB 25.56 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +1.31% 108.67 kB 110.09 kB +1.51% 25.18 kB 25.56 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.31% 103.18 kB 104.53 kB +1.70% 24.91 kB 25.34 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.31% 103.18 kB 104.53 kB +1.70% 24.91 kB 25.34 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +1.30% 103.45 kB 104.80 kB +1.71% 24.37 kB 24.79 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.26% 106.86 kB 108.21 kB +1.64% 25.47 kB 25.89 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.26% 106.86 kB 108.21 kB +1.64% 25.47 kB 25.89 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +1.25% 107.64 kB 108.98 kB +1.62% 25.70 kB 26.12 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +1.25% 113.77 kB 115.19 kB +1.42% 26.06 kB 26.43 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +1.25% 108.05 kB 109.39 kB +1.63% 25.82 kB 26.24 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.24% 108.91 kB 110.25 kB +1.60% 26.11 kB 26.53 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.24% 108.91 kB 110.25 kB +1.60% 26.11 kB 26.53 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1.21% 111.28 kB 112.62 kB +1.59% 26.23 kB 26.65 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +1.19% 113.32 kB 114.67 kB +1.56% 26.84 kB 27.26 kB
oss-stable-semver/react-server/cjs/react-server-flight.production.min.js +0.85% 16.50 kB 16.64 kB +0.78% 5.93 kB 5.97 kB
oss-stable/react-server/cjs/react-server-flight.production.min.js +0.85% 16.50 kB 16.64 kB +0.78% 5.93 kB 5.97 kB
oss-experimental/react-server/cjs/react-server-flight.production.min.js +0.79% 17.63 kB 17.77 kB +0.69% 6.21 kB 6.25 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +0.56% 25.15 kB 25.29 kB +0.49% 8.70 kB 8.74 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +0.56% 25.15 kB 25.29 kB +0.49% 8.70 kB 8.74 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.min.js +0.54% 26.31 kB 26.45 kB +0.51% 8.99 kB 9.03 kB
oss-stable-semver/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +0.53% 26.68 kB 26.82 kB +0.48% 9.12 kB 9.16 kB
oss-stable/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +0.53% 26.68 kB 26.82 kB +0.48% 9.12 kB 9.16 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +0.53% 26.52 kB 26.66 kB +0.46% 8.99 kB 9.03 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +0.53% 26.52 kB 26.66 kB +0.46% 8.99 kB 9.03 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +0.53% 26.84 kB 26.98 kB +0.52% 9.10 kB 9.14 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +0.53% 26.84 kB 26.98 kB +0.52% 9.10 kB 9.14 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.min.js +0.51% 27.73 kB 27.87 kB +0.46% 9.29 kB 9.33 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.min.js +0.50% 28.05 kB 28.19 kB +0.54% 9.40 kB 9.45 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.production.min.js +0.50% 27.90 kB 28.04 kB +0.57% 9.41 kB 9.47 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0.50% 27.97 kB 28.11 kB +0.51% 9.49 kB 9.54 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0.50% 27.97 kB 28.11 kB +0.51% 9.49 kB 9.54 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +0.49% 28.50 kB 28.64 kB +0.52% 9.65 kB 9.70 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +0.49% 28.50 kB 28.64 kB +0.52% 9.65 kB 9.70 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0.48% 29.13 kB 29.27 kB +0.41% 9.78 kB 9.82 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.min.js +0.48% 29.66 kB 29.80 kB +0.45% 9.95 kB 9.99 kB
oss-stable-semver/react/cjs/react.shared-subset.development.js +0.24% 84.72 kB 84.93 kB +0.38% 23.50 kB 23.59 kB
oss-stable/react/cjs/react.shared-subset.development.js +0.24% 84.75 kB 84.95 kB +0.39% 23.53 kB 23.62 kB
oss-experimental/react/cjs/react.shared-subset.development.js +0.24% 86.40 kB 86.61 kB +0.37% 24.00 kB 24.09 kB
oss-stable-semver/react/cjs/react.development.js +0.21% 99.79 kB 99.99 kB +0.32% 26.94 kB 27.03 kB
oss-stable/react/cjs/react.development.js +0.21% 99.81 kB 100.02 kB +0.33% 26.97 kB 27.06 kB
oss-experimental/react/cjs/react.development.js +0.20% 102.28 kB 102.49 kB +0.30% 27.60 kB 27.68 kB

Generated by 🚫 dangerJS against 6b3290b

Copy link
Collaborator

@gnoff gnoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit spelling

packages/react/src/ReactServerContext.js Outdated Show resolved Hide resolved
packages/react/src/ReactServerContext.js Outdated Show resolved Hide resolved
// $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED,
);
const context: ReactServerContext<any> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this inlined now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is because we don’t want to warn when this method is called which is used internally in react

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea and I plan on literally deleting the code soon so meh.

@hamlim
Copy link
Contributor

hamlim commented Sep 28, 2023

(let me know if this is better to add in an issue / discussion instead)

I (partially) understand the pitfall that comes with Server Context, but I'm curious what the recommended path forward would be for "parent-child context" (can't think of a more apt name at the moment) within Server Components.

For example, if I'm using something like MDX that translates markdown content to React components, I would want to know if a <code> element was rendered within a <pre> element to render a <CodeBlock /> component or an <InlineCode /> component respectively. Currently I use Server Context to communicate to the generic Code component if it's within a pre element or not.

Here's a code reference with that pattern: https://github.com/hamlim/blog/blob/main/lib/MDXComponents.tsx#L70-L93

I suppose an alternative might be AsyncLocalStorage, and the Pre component calls enterWith with that "context", and the Code component grabs the value from the store - however that might not fully work, I'll have to test it out.

@sebmarkbage
Copy link
Collaborator Author

@hamlim The general recommendation is just to pass it manually. Most of the time it's not the end of the world. You can also pass grouped things like a general Context object that has more than one thing in it to make it easy to pass just one thing.

In the MDX case, since it's all generated code anyway, an option here is to just let the generated code pass an extra "context" prop to all these components. The user doesn't have to even know.

There are perhaps other new features that frameworks can provide (like maybe Next.js can give access to part of the URL like i18n) that can be specific solutions to specific problems.

@sebmarkbage sebmarkbage merged commit 1ebedbe into facebook:main Sep 28, 2023
2 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 28, 2023
As agreed, we're removing Server Context. This was never official
documented.

We've found that it's not that useful in practice. Often the better
options are:

- Read things off the url or global scope like params or cookies.
- Use the module system for global dependency injection.
- Use `React.cache()` to dedupe multiple things instead of computing
once and passing down.

There are still legit use cases for Server Context but you have to be
very careful not to pass any large data, so in generally we recommend
against it anyway.

Yes, prop drilling is annoying but it's not impossible for the cases
this is needed. I would personally always pick it over Server Context
anyway.

Semantically, Server Context also blocks object deduping due to how it
plays out with Server Components that can't be deduped. This is much
more important feature.

Since it's already in canary along with the rest of RSC, we're adding a
warning for a few versions before removing completely to help migration.

---------

Co-authored-by: Josh Story <[email protected]>

DiffTrain build for [1ebedbe](1ebedbe)
@lazarv
Copy link

lazarv commented Sep 30, 2023

The general recommendation is just to pass it manually.

@sebmarkbage Server Context was very useful to not do the prop-drilling way, which is just awful. In many cases the child just need to know about a context and knows nothing about from where that context was received and the parent providing that context doesn't know about what type of child will consume the context.

I also understand all the issues and communication around Server Contexts, but sad to see it leaving.

@hamlim AsyncLocalStorage seems analogous for the Server Context, but it essentially works differently. With React the rendering order of components will not allow using the AsyncLocalStorage when the store is provided from within a component render. At least I don't see any way it would be possible.

kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Oct 3, 2023
Today when we hydrate an SSR'd RSC response on the client we encounter import chunks which initiate code loading for client components. However we only start fetching these chunks after hydration has begun which is necessarily after the initial chunks for the entrypoint have loaded.

React has upstream changes that need to land which will preinitialize the rendered chunks for all client components used during the SSR pass. This will cause a `<script async="" src... />` tag to be emitted in the head for each chunk we need to load during hydration which allows the browser to start fetching these resources even before the entrypoint has started to execute.

Additionally the implementation for webpack and turbopack is different enough that there will be a new `react-server-dom-turbopack` package in the React repo which should be used when using Turbopack with Next.

This PR also removes a number of patches to React src that proxy loading (`__next_chunk_load__`) and bundler requires (`__next_require__`) through the `globalThis` object. Now the react packages can be fully responsible for implementing chunk loading and all Next needs to do is supply the necessary information such as chunk prefix and crossOrigin attributes necessary for this loading. This information is produced as part of the client-manifest by either a Webpack plugin or Turbopack.

Additionally any modifications to the chunk filename that were previously done at runtime need to be made in the manifest itself now. This means we need to encode the deployment id for skew protection and encode the filename to make it match our static path matching (and resolutions on s3) when using `[` and `]` segment characters.

There are a few followup items to consider in later PRs
1. we currently bundle a node and edge version of react-server-dom-webpack/client. The node version has an implementation for busboy whereas the edge version does not. Next is currently configured to use busboy when handling a fetch action sent as multipart with a node runtime. Ideally we'd only bundle the one platform we are buliding for but some additional refactoring to support better forking is possibly required here

This PR also updates react from 09285d5a7 to d900fadbf.

### React upstream changes

- facebook/react#27439
- facebook/react#26763
- facebook/react#27434
- facebook/react#27433
- facebook/react#27424
- facebook/react#27428
- facebook/react#27427
- facebook/react#27315
- facebook/react#27314
- facebook/react#27400
- facebook/react#27421
- facebook/react#27419
- facebook/react#27418
sebmarkbage added a commit that referenced this pull request Oct 11, 2023
We previously added a warning in #27424. This just removes it from
canary/stable channels but keeps it in experimental for now.
github-actions bot pushed a commit that referenced this pull request Oct 11, 2023
We previously added a warning in #27424. This just removes it from
canary/stable channels but keeps it in experimental for now.

DiffTrain build for [1fc5828](1fc5828)
alunyov pushed a commit to alunyov/react that referenced this pull request Oct 11, 2023
We previously added a warning in facebook#27424. This just removes it from
canary/stable channels but keeps it in experimental for now.
unstubbable added a commit to unstubbable/mfng that referenced this pull request Oct 31, 2023
Because [server context has been
deprecated](facebook/react#27424), we needed to
find a replacement for sharing the current location.

Using conditional exports, we can create a universal `useRouterLocation`
hook that utilizes `AsyncLocalStorage` on the server, and normal client
context in the browser. Even though the client context would also be
accessible in the SSR client (we could render the context provider in
`ServerRoot`), we are instead using `AsyncLocalStorage` here as well,
primarily for its convenience. Although this requires placing the module
containing the `AsyncLocalStorage` instance into a shared webpack layer.
unstubbable added a commit to unstubbable/mfng that referenced this pull request Oct 31, 2023
Because [server context has been
deprecated](facebook/react#27424), we needed to
find a replacement for sharing the current location.

Using conditional exports, we can create a universal `useRouterLocation`
hook that utilizes `AsyncLocalStorage` on the server, and normal client
context in the browser. Even though the client context would also be
accessible in the SSR client (we could render the context provider in
`ServerRoot`), we are instead using `AsyncLocalStorage` here as well,
primarily for its convenience. Although this does require placing the
module containing the `AsyncLocalStorage` instance into a shared webpack
layer.
unstubbable added a commit to unstubbable/mfng that referenced this pull request Oct 31, 2023
Because [server context has been
deprecated](facebook/react#27424), we needed to
find a replacement for sharing the current location.

Using conditional exports, we can create a universal `useRouterLocation`
hook that utilizes `AsyncLocalStorage` on the server, and normal client
context in the browser. Even though the client context would also be
accessible in the SSR client (we could render the context provider in
`ServerRoot`), we are instead using `AsyncLocalStorage` here as well,
primarily for its convenience. Although this does require placing the
module containing the `AsyncLocalStorage` instance into a shared webpack
layer.
@eric-burel
Copy link

For the record, in an article that shortly followed the release of RSCs, I called "Server Context" the idea of sharing data across RSCs, symmetrically to the existing React "Client Context".

I still see many beginners in need for this, it's not obvious to everybody how to avoid props drilling when you have only RSCs.

@karlhorky pointed a potential name clash with the name "Server Context" as being a way to pass context from RSC to client transparently.

Since it's now deprecated, perhaps the "Server Context" wording could be reused again for the pattern I described?

gaearon added a commit that referenced this pull request Feb 5, 2024
Server Context was never documented, and has been deprecated in
#27424.

This PR removes it completely, including the implementation code.

Notably, `useContext` is removed from the shared subset, so importing it
from a React Server environment would now should be a build error in
environments that are able to enforce that.
github-actions bot pushed a commit that referenced this pull request Feb 5, 2024
Server Context was never documented, and has been deprecated in
#27424.

This PR removes it completely, including the implementation code.

Notably, `useContext` is removed from the shared subset, so importing it
from a React Server environment would now should be a build error in
environments that are able to enforce that.

DiffTrain build for [4728548](4728548)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
As agreed, we're removing Server Context. This was never official
documented.

We've found that it's not that useful in practice. Often the better
options are:

- Read things off the url or global scope like params or cookies.
- Use the module system for global dependency injection.
- Use `React.cache()` to dedupe multiple things instead of computing
once and passing down.

There are still legit use cases for Server Context but you have to be
very careful not to pass any large data, so in generally we recommend
against it anyway.

Yes, prop drilling is annoying but it's not impossible for the cases
this is needed. I would personally always pick it over Server Context
anyway.

Semantically, Server Context also blocks object deduping due to how it
plays out with Server Components that can't be deduped. This is much
more important feature.

Since it's already in canary along with the rest of RSC, we're adding a
warning for a few versions before removing completely to help migration.

---------

Co-authored-by: Josh Story <[email protected]>
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
We previously added a warning in facebook#27424. This just removes it from
canary/stable channels but keeps it in experimental for now.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Server Context was never documented, and has been deprecated in
facebook#27424.

This PR removes it completely, including the implementation code.

Notably, `useContext` is removed from the shared subset, so importing it
from a React Server environment would now should be a build error in
environments that are able to enforce that.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
As agreed, we're removing Server Context. This was never official
documented.

We've found that it's not that useful in practice. Often the better
options are:

- Read things off the url or global scope like params or cookies.
- Use the module system for global dependency injection.
- Use `React.cache()` to dedupe multiple things instead of computing
once and passing down.

There are still legit use cases for Server Context but you have to be
very careful not to pass any large data, so in generally we recommend
against it anyway.

Yes, prop drilling is annoying but it's not impossible for the cases
this is needed. I would personally always pick it over Server Context
anyway.

Semantically, Server Context also blocks object deduping due to how it
plays out with Server Components that can't be deduped. This is much
more important feature.

Since it's already in canary along with the rest of RSC, we're adding a
warning for a few versions before removing completely to help migration.

---------

Co-authored-by: Josh Story <[email protected]>

DiffTrain build for commit 1ebedbe.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
We previously added a warning in #27424. This just removes it from
canary/stable channels but keeps it in experimental for now.

DiffTrain build for commit 1fc5828.
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.

8 participants