-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Element: export new React 18 APIs #46610
Conversation
Size Change: -3.33 kB (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this one! I wonder if you'd like to add a few more of the new APIs that we'll likely use or at least experiment with in the near future.
@@ -43,6 +44,20 @@ export { render }; | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a @deprecated
for render()
and hydrate()
now that they are deprecated in React 18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we if add @deprecated, we need to also add a real deprecated function call, so let's leave it for later when we migrate all of our usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Maybe adding a comment would suffice then.
@@ -198,6 +198,14 @@ _Returns_ | |||
|
|||
- `Object`: Ref object. | |||
|
|||
### createRoot | |||
|
|||
Creates a new React root for the target DOM node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An ideal place to mention that these are deprecated now in React 18.
/** | ||
* @see https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore | ||
*/ | ||
export { useSyncExternalStore }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add the rest of the new hooks (useId
, useTransition
, useDeferredValue
, useInsertionEffect
)? I can immediately see opportunities for almost all of them.
Note that if we add useTransition
we might want to expose startTransition
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, pushed a commit that exports them all.
* @see https://reactjs.org/docs/react-dom-client.html#hydrateroot | ||
*/ | ||
export { hydrateRoot }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also expose Suspense
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suspense
has already been exposed for some time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks 🚀
Starts exporting new React 18 API from
@wordpress/element
. A standalone PR we'll later use in #46467 (createRoot
and concurrent mode) and in #46606 (useSelect
withuseSyncExternalStore
).