Skip to content
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

React 19 compatibility #37951

Closed
12 tasks done
Tracked by #36721
coder-karen opened this issue Jun 19, 2024 · 3 comments
Closed
12 tasks done
Tracked by #36721

React 19 compatibility #37951

coder-karen opened this issue Jun 19, 2024 · 3 comments
Assignees
Labels
Epic Formerly "Primary Issue", or "Master Issue" General [Type] Janitorial

Comments

@coder-karen
Copy link
Contributor

coder-karen commented Jun 19, 2024

In WordPress 6.6, version 18.3 of the React library will be shipped, which will include warnings for deprecations and other changes that will ship in version 19 of React.

We should ensure compatibility with React 19.


propTypes and defaultProps will be removed for functions (though defaultProps will continue to be supported for class components). If propTypes is in use in a TypeScript file this is absolutely fine.

The propTypes issue is here (now closed): #38271

A fix for defaultProps was made #38274, but another instance still needs fixing: Warning: Connect(SettingsForm): Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead. (from the Jetpack settings page, ref p1721282023991279-slack-CDLH4C1UZ).

Done in #38539


react-test-renderer/shallow will be removed, and instead can be installed directly from react-shallow-renderer. Related - react-test-renderer will be deprecated.

Done in #38753


unmountComponentAtNode will be removed, root.unmount() can be used instead.

Done in #38618


ReactDOM.findDOMNode will be removed and can be replaced with DOM refs.

Done in #37408


Typescript related:

The global JSX namespace has been removed in favor of React.JSX.

Done in #38585


JSX transform / polyfill:

Done in #38428


Additionally, in React 18 importing createRoot from react-dom was deprecated.

Done in #38495


Also, in React 19 ReactDOM.render will be removed and we'll need to be using ReactDOM.createRoot:

Done in #38644


Typescript related, returning anything else from a ref callback will now be rejected by TypeScript.

Done in #38761


Typescript and React related - useRef now requires an argument.

Done in #38763


Error generation with javascript:url usage

Done in #38780

Tasks

  1. General [Type] Janitorial
    coder-karen
  2. [Type] Janitorial
    coder-karen
  3. [Type] Janitorial
    coder-karen
  4. [Focus] Compatibility [Platform] Atomic [Platform] Simple [Plugin] Jetpack [Pri] Normal [Type] Bug [Type] Janitorial
    coder-karen
  5. [Type] Janitorial
    coder-karen
  6. coder-karen
  7. [Type] Janitorial
    coder-karen
  8. General [Type] Janitorial
    coder-karen
  9. General [Type] Janitorial
    coder-karen
  10. [Type] Janitorial
    coder-karen
  11. [Type] Janitorial
    coder-karen
  12. [Type] Janitorial
    coder-karen

General ref: https://make.wordpress.org/core/2024/06/07/preparation-for-react-19-upgrade/

@anomiex
Copy link
Contributor

anomiex commented Jun 20, 2024

Something else we'll want to consider is switching to the new jsx transform if we're not already using it everywhere. Or, more specifically, whether we want to "polyfill" the react-jsx-runtime script being added to WordPress core in 6.6 for as long as we continue to support 6.5, or continue with letting the jsx runtime be included in our bundles until we drop 6.5.

@zinigor
Copy link
Member

zinigor commented Jul 1, 2024

As far as I could find, we're not affected by either dropping the react-shallow-renderer/shallow, nor the unmountComponentNode calls. So from my understanding, the major problem is the propType, because it's abundant in Jetpack code. It's not actually breaking because it's simply going to get ignored, but still that's not a good thing.

So we should prioritize the JSX transform changes and polyfill, and the findDomNode usage.

@coder-karen
Copy link
Contributor Author

Marking this as done now, I believe I've covered any relevant React 19 compatibility issues.

So from my understanding, the major problem is the propType, because it's abundant in Jetpack code. It's not actually breaking because it's simply going to get ignored, but still that's not a good thing.

@zinigor I did want to follow up on this comment specifically though, to say that after looking into it more I believe it's not relevant for us - I commented here: #38271 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Formerly "Primary Issue", or "Master Issue" General [Type] Janitorial
4 participants