Moving createRoot/hydrateRoot to react-dom/client #125
Replies: 2 comments 12 replies
-
If I’ve also noticed that you are using inconsistent import styles and I believe that it should be fixed - either stick to a default import or to a namespace import |
Beta Was this translation helpful? Give feedback.
-
@eps1lon did u have a chance to rethink the impact on the libraries that you maintain (such as RTL)? Is React team still OK with making it impossible/hard for certain libraries to depend on |
Beta Was this translation helpful? Give feedback.
-
Overview
For the next React 18 RC (RC 1) we're moving both
createRoot
andhydrateRoot
toreact-dom/client
:Using these APIs from the top level will now warn.
Motivation
There are two reasons for this change.
First, it allows components to use the isomorphic APIs such as
flushSync
without pulling in the client-specific entry. This means that if you server render a component that only usesflushSync
on the client, the server doesn't need to pull in the client-specific code forcreateRoot
orhydrateRoot
.Second, it creates parity with
react-dom/server
:Before:
After:
Warnings
When you first upgrade to RC 1 from previous React 18 pre-release versions, you'll see a warning when using the top level functions.
For
createRoot
:For
hydrateRoot
:For more information see facebook/react#23385
Beta Was this translation helpful? Give feedback.
All reactions