[react-dom] move all client code to react-dom/client#28271
Merged
gnoff merged 2 commits intofacebook:mainfrom Apr 24, 2024
Merged
[react-dom] move all client code to react-dom/client#28271gnoff merged 2 commits intofacebook:mainfrom
react-dom/client#28271gnoff merged 2 commits intofacebook:mainfrom
Conversation
f095713 to
af1c41d
Compare
5b4b06c to
91a323d
Compare
Member
|
@gnoff I checked and we do have an error for:
But it looks old and not shown anywhere |
sebmarkbage
reviewed
Feb 15, 2024
|
|
||
| throw new Error( | ||
| 'react-dom/client is not supported in React Server Components.' | ||
| ); |
Contributor
There was a problem hiding this comment.
This should also be the same for react-dom/server since an SSR render consumes Client Components which don't exist in a react-server layer.
63bb27d to
ac9b2af
Compare
…ternal module boundaries that get picked up by devtoools timeline testing. This udpates snapshots to reflect this expected change.
rickhanlonii
approved these changes
Apr 24, 2024
github-actions bot
pushed a commit
that referenced
this pull request
Apr 24, 2024
This PR reorganizes the `react-dom` entrypoint to only pull in code that is environment agnostic. Previously if you required anything from this entrypoint in any environment the entire client reconciler was loaded. In a prior release we added a server rendering stub which you could alias in server environments to omit this unecessary code. After landing this change this entrypoint should not load any environment specific code. While a few APIs are truly client (browser) only such as createRoot and hydrateRoot many of the APIs you import from this package are only useful in the browser but could concievably be imported in shared code (components running in Fizz or shared components as part of an RSC app). To avoid making these require opting into the client bundle we are keeping them in the `react-dom` entrypoint and changing their implementation so that in environments where they are not particularly useful they do something benign and expected. #### Removed APIs The following APIs are being removed in the next major. Largely they have all been deprecated already and are part of legacy rendering modes where concurrent features of React are not available * `render` * `hydrate` * `findDOMNode` * `unmountComponentAtNode` * `unstable_createEventHandle` * `unstable_renderSubtreeIntoContainer` * `unstable_runWithPrioirty` #### moved Client APIs These APIs were available on both `react-dom` (with a warning) and `react-dom/client`. After this change they are only available on `react-dom/client` * `createRoot` * `hydrateRoot` #### retained APIs These APIs still exist on the `react-dom` entrypoint but have normalized behavior depending on which renderers are currently in scope * `flushSync`: will execute the function (if provided) inside the flushSync implemention of FlightServer, Fizz, and Fiber DOM renderers. * `unstable_batchedUpdates`: This is a noop in concurrent mode because it is now the only supported behavior because there is no legacy rendering mode * `createPortal`: This just produces an object. It can be called from anywhere but since you will probably not have a handle on a DOM node to pass to it it will likely warn in environments other than the browser * preloading APIS such as `preload`: These methods will execute the preload across all renderers currently in scope. Since we resolve the Request object on the server using AsyncLocalStorage or the current function stack in practice only one renderer should act upon the preload. In addition to these changes the server rendering stub now just rexports everything from `react-dom`. In a future minor we will add a warning when using the stub and in the next major we will remove the stub altogether DiffTrain build for commit cb15184.
github-actions bot
pushed a commit
that referenced
this pull request
Apr 24, 2024
This PR reorganizes the `react-dom` entrypoint to only pull in code that is environment agnostic. Previously if you required anything from this entrypoint in any environment the entire client reconciler was loaded. In a prior release we added a server rendering stub which you could alias in server environments to omit this unecessary code. After landing this change this entrypoint should not load any environment specific code. While a few APIs are truly client (browser) only such as createRoot and hydrateRoot many of the APIs you import from this package are only useful in the browser but could concievably be imported in shared code (components running in Fizz or shared components as part of an RSC app). To avoid making these require opting into the client bundle we are keeping them in the `react-dom` entrypoint and changing their implementation so that in environments where they are not particularly useful they do something benign and expected. #### Removed APIs The following APIs are being removed in the next major. Largely they have all been deprecated already and are part of legacy rendering modes where concurrent features of React are not available * `render` * `hydrate` * `findDOMNode` * `unmountComponentAtNode` * `unstable_createEventHandle` * `unstable_renderSubtreeIntoContainer` * `unstable_runWithPrioirty` #### moved Client APIs These APIs were available on both `react-dom` (with a warning) and `react-dom/client`. After this change they are only available on `react-dom/client` * `createRoot` * `hydrateRoot` #### retained APIs These APIs still exist on the `react-dom` entrypoint but have normalized behavior depending on which renderers are currently in scope * `flushSync`: will execute the function (if provided) inside the flushSync implemention of FlightServer, Fizz, and Fiber DOM renderers. * `unstable_batchedUpdates`: This is a noop in concurrent mode because it is now the only supported behavior because there is no legacy rendering mode * `createPortal`: This just produces an object. It can be called from anywhere but since you will probably not have a handle on a DOM node to pass to it it will likely warn in environments other than the browser * preloading APIS such as `preload`: These methods will execute the preload across all renderers currently in scope. Since we resolve the Request object on the server using AsyncLocalStorage or the current function stack in practice only one renderer should act upon the preload. In addition to these changes the server rendering stub now just rexports everything from `react-dom`. In a future minor we will add a warning when using the stub and in the next major we will remove the stub altogether DiffTrain build for [cb15184](cb15184)
This was referenced Apr 24, 2024
bigfootjon
pushed a commit
that referenced
this pull request
Apr 25, 2024
This PR reorganizes the `react-dom` entrypoint to only pull in code that is environment agnostic. Previously if you required anything from this entrypoint in any environment the entire client reconciler was loaded. In a prior release we added a server rendering stub which you could alias in server environments to omit this unecessary code. After landing this change this entrypoint should not load any environment specific code. While a few APIs are truly client (browser) only such as createRoot and hydrateRoot many of the APIs you import from this package are only useful in the browser but could concievably be imported in shared code (components running in Fizz or shared components as part of an RSC app). To avoid making these require opting into the client bundle we are keeping them in the `react-dom` entrypoint and changing their implementation so that in environments where they are not particularly useful they do something benign and expected. #### Removed APIs The following APIs are being removed in the next major. Largely they have all been deprecated already and are part of legacy rendering modes where concurrent features of React are not available * `render` * `hydrate` * `findDOMNode` * `unmountComponentAtNode` * `unstable_createEventHandle` * `unstable_renderSubtreeIntoContainer` * `unstable_runWithPrioirty` #### moved Client APIs These APIs were available on both `react-dom` (with a warning) and `react-dom/client`. After this change they are only available on `react-dom/client` * `createRoot` * `hydrateRoot` #### retained APIs These APIs still exist on the `react-dom` entrypoint but have normalized behavior depending on which renderers are currently in scope * `flushSync`: will execute the function (if provided) inside the flushSync implemention of FlightServer, Fizz, and Fiber DOM renderers. * `unstable_batchedUpdates`: This is a noop in concurrent mode because it is now the only supported behavior because there is no legacy rendering mode * `createPortal`: This just produces an object. It can be called from anywhere but since you will probably not have a handle on a DOM node to pass to it it will likely warn in environments other than the browser * preloading APIS such as `preload`: These methods will execute the preload across all renderers currently in scope. Since we resolve the Request object on the server using AsyncLocalStorage or the current function stack in practice only one renderer should act upon the preload. In addition to these changes the server rendering stub now just rexports everything from `react-dom`. In a future minor we will add a warning when using the stub and in the next major we will remove the stub altogether DiffTrain build for commit cb15184.
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 27, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 27, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 27, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 28, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 29, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
Apr 30, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 2, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 2, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 3, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 6, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 6, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 6, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 7, 2024
No longer needed now that facebook/react#28271 exists
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 7, 2024
No longer needed now that facebook/react#28271 exists
hoxyq
added a commit
that referenced
this pull request
May 8, 2024
Full list of changes (not a public changelog): * fix[react-devtools/ci]: fix configurations for e2e testing ([hoxyq](https://github.com/hoxyq) in [#29016](#29016)) * feat[react-devtools]: display forget badge for components in profiling session ([hoxyq](https://github.com/hoxyq) in [#29014](#29014)) * fix[react-devtools]: add backwards compat with legacy element type symbol ([hoxyq](https://github.com/hoxyq) in [#28982](#28982)) * Expose "view source" options to Fusebox integration ([motiz88](https://github.com/motiz88) in [#28973](#28973)) * Enable inspected element context menu in Fusebox ([motiz88](https://github.com/motiz88) in [#28972](#28972)) * Check in `frontend.d.ts` for react-devtools-fusebox, include in build output ([motiz88](https://github.com/motiz88) in [#28970](#28970)) * Devtools: Fix build-for-devtools ([eps1lon](https://github.com/eps1lon) in [#28976](#28976)) * Move useMemoCache hook to react/compiler-runtime ([kassens](https://github.com/kassens) in [#28954](#28954)) * warn -> error for Test Renderer deprecation ([acdlite](https://github.com/acdlite) in [#28904](#28904)) * [react-dom] move all client code to `react-dom/client` ([gnoff](https://github.com/gnoff) in [#28271](#28271)) * Rename the react.element symbol to react.transitional.element ([sebmarkbage](https://github.com/sebmarkbage) in [#28813](#28813)) * Rename Forget badge ([jbonta](https://github.com/jbonta) in [#28858](#28858)) * Devtools: Add support for useFormStatus ([eps1lon](https://github.com/eps1lon) in [#28413](#28413))
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 free
to 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.
This PR reorganizes the
react-domentrypoint to only pull in code that is environment agnostic. Previously if you required anything from this entrypoint in any environment the entire client reconciler was loaded. In a prior release we added a server rendering stub which you could alias in server environments to omit this unecessary code. After landing this change this entrypoint should not load any environment specific code.While a few APIs are truly client (browser) only such as createRoot and hydrateRoot many of the APIs you import from this package are only useful in the browser but could concievably be imported in shared code (components running in Fizz or shared components as part of an RSC app). To avoid making these require opting into the client bundle we are keeping them in the
react-domentrypoint and changing their implementation so that in environments where they are not particularly useful they do something benign and expected.Removed entrypoints
react-dom/server-rendering-stubhas been removed sincereact-domwill no longer contain client code.Removed APIs
The following APIs are being removed in the next major. Largely they have all been deprecated already and are part of legacy rendering modes where concurrent features of React are not available
renderhydratefindDOMNodeunmountComponentAtNodeunstable_createEventHandleunstable_renderSubtreeIntoContainerunstable_runWithPrioirtymoved Client APIs
These APIs were available on both
react-dom(with a warning) andreact-dom/client. After this change they are only available onreact-dom/clientcreateRoothydrateRootretained APIs
These APIs still exist on the
react-domentrypoint but have normalized behavior depending on which renderers are currently in scopeflushSync: will execute the function (if provided) inside the flushSync implemention of FlightServer, Fizz, and Fiber DOM renderers.unstable_batchedUpdates: This is a noop in concurrent mode because it is now the only supported behavior because there is no legacy rendering modecreatePortal: This just produces an object. It can be called from anywhere but since you will probably not have a handle on a DOM node to pass to it it will likely warn in environments other than the browserpreload: These methods will execute the preload across all renderers currently in scope. Since we resolve the Request object on the server using AsyncLocalStorage or the current function stack in practice only one renderer should act upon the preload.In addition to these changes the server rendering stub now just rexports everything from
react-dom. In a future minor we will add a warning when using the stub and in the next major we will remove the stub altogether