mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
92.41k stars 31.82k forks source link

[core] Support React 19 #42381

Open DiegoAndai opened 1 month ago

DiegoAndai commented 1 month ago

Summary

Tasks:

Examples

Motivation

Allow users to use packages with React 19 to make the most out of the new features

Search keywords: react 19 support

oliviertassinari commented 3 weeks ago

Do we plan to bring React 19 support to Material UI v5? From this issue, I get the impression that it's plan for Material UI v6 only.

I think that we could skip Material UI v5 support, and only do Material UI v6 if all these conditions are met:

aarongarciah commented 3 weeks ago

@DiegoAndai I created an issue to adopt the official eslint-plugin-react-compiler. React compiler requires React 19 to work, so it would be nice if we fix most issues (at least in the demos) before React 19 is released.

Do you think it makes sense to include it in this umbrella issue?

edit: https://github.com/mui/material-ui/issues/42548 is now part of this umbrella issue.

DiegoAndai commented 3 weeks ago

Do we plan to bring React 19 support to Material UI v5?

We discussed with the core team, and the plan is as follows:

To make the backport easier (in case we go for it), we'll try to batch the React 19 changes in bigger PRs.

cc: @aarongarciah

oliviertassinari commented 3 weeks ago

@DiegoAndai It sounds great.

The why behind each condition is more important than the conditions themselves, I wanted to highlight the considerations that we likely want to weight with v4.

fzaninotto commented 3 weeks ago

I know the decision has already been made, but I wanted to give my 2c with the react-admin perspective.

We're adding the finishing touches to our new major version, react-admin v5. We do only one major version every 2 years to avoid bothering our users with useless upgrades, so we make each major count!

We've tested react-admin v5 with React 19 RC, and we only have only 2 problems (we're using Material UI v5):

We would very much like to launch React-admin v5 just after the React 19 stable, to be able to benefit from the new hooks (e.g. use()) in future minor releases. Otherwise we'll have to wait 2 years for that. But that won't be possible if MUI v5 doesn't fix the two issues above or if V6 isn't released in the days following React 19.

I dont't know about the MUI v6 release schedule, but I understand it's not ready for prime time yet. So if you could fix the 2 issues above in v5 first, this would help react-admin (and every other project using MUI v5 and React 19) work almost flawlessly without waiting for V6.

We could even give you a hand if that's an option.

Looking forward to using React 19 with MUI soon!

DiegoAndai commented 2 weeks ago

Thanks for reaching out @fzaninotto 🙌🏼

This is a solid argument for backporting the React 19 changes to v5. If we can support React 19 without breaking changes, I see it likely that we will. We'll keep updating this issue with the progress we make.

fzaninotto commented 1 week ago

We ended up releasing react-admin v5 today without requiring React 19 (or MUI 6). We'll need to wait for the next major version to do so. https://github.com/marmelab/react-admin/releases/tag/v5.0.0.

Zenoo commented 6 days ago

I'm not sure if this warning is known, so I'll add it here just in case. It's about element.ref in React 19:

app-index.js:34 Warning: Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.
    at Tooltip (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/@mui+material@5.15.20_@emotion+react@11.11.4_@types+react@18.3.3_react@19.0.0-rc-f994737d14-2_gr7z7qewvkqf543mugcy52trle/node_modules/@mui/material/Tooltip/Tooltip.js:294:85)

It's not having any negative impact on the actual display.