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

[material-ui] Accessing element.ref was removed in React 19 #42604

Closed
Tracked by #42381
oliviertassinari opened this issue Jun 10, 2024 · 2 comments · Fixed by #42818
Closed
Tracked by #42381

[material-ui] Accessing element.ref was removed in React 19 #42604

oliviertassinari opened this issue Jun 10, 2024 · 2 comments · Fixed by #42818
Assignees
Labels
bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module!

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 10, 2024

In React 19, ref is now a prop and should be accessed through props.ref. We have some instances of this we should fix: https://github.com/search?q=repo:mui/material-ui%20children.ref&type=code

Example with Tooltip

https://codesandbox.io/p/sandbox/silly-sea-m9cjyn?file=%2Fsrc%2FDemo.tsx

import * as React from "react";
import Tooltip from "@mui/material/Tooltip";

export default function BasicTooltip() {
  const ref = React.useRef();
  return (
    <Tooltip title="Delete">
      <button ref={ref}>hello</button>
    </Tooltip>
  );
}
SCR-20240610-pupd

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 (node_modules/@mui/material/Tooltip/Tooltip.js:294:85)

Context

const handleRef = useForkRef(children.ref, focusVisibleRef, setChildNode, ref);

Your environment

react v19.0.0-rc.0
@mui/material v5.15.19

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module! status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 10, 2024
@DiegoAndai DiegoAndai self-assigned this Jun 10, 2024
@DiegoAndai DiegoAndai removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 10, 2024
@DiegoAndai DiegoAndai changed the title [react 19][tooltip] Accessing element.ref was removed in React 19 [material-ui] Accessing element.ref was removed in React 19 Jul 2, 2024
@DiegoAndai
Copy link
Member

Updated issue so it covers all cases and not only the Tooltip one.

@luc-nham
Copy link

The Select component also appears the warning. My environment:

  • Rect 19 Cavani
  • Mui 5x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants