Element: export new React 18 APIs#46610
Conversation
|
Size Change: -3.33 kB (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
tyxla
left a comment
There was a problem hiding this comment.
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.
Should we add a @deprecated for render() and hydrate() now that they are deprecated in React 18?
There was a problem hiding this comment.
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.
Sure. Maybe adding a comment would suffice then.
|
|
||
| ### createRoot | ||
|
|
||
| Creates a new React root for the target DOM node. |
There was a problem hiding this comment.
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.
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.
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.
Suspense has already been exposed for some time.
Starts exporting new React 18 API from
@wordpress/element. A standalone PR we'll later use in #46467 (createRootand concurrent mode) and in #46606 (useSelectwithuseSyncExternalStore).