dillon1000/react
Commit
Browse files Add Server Context deprecation warning (#27424)
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]>
Changed paths5 files
First-parent comparisonpackages/react-client/src/__tests__/ReactFlight-test.js ModifiedM packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js ModifiedM packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js ModifiedM packages/react/src/ReactServerContext.js ModifiedM packages/shared/ReactServerContextRegistry.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…