-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tooltip] Error message from using a class component #33152
Comments
Non-ref forwarding class components are not supported by the Tooltip (#21811). |
@michaldudak Thank you. I had figured that out and was able to work around it, but I also wondered if MUI's |
Yes, that's a good idea. I'd check for |
@michaldudak Done; see #33323. |
Duplicates
Latest version
Current behavior 馃槸
If a React class component is used as the child of an MUI Tooltip, you get an exception with a somewhat cryptic error message. In Chrome:
In Firefox:
Full stack trace in Chrome
Expected behavior 馃
It works, or a clean error message is shown.
Steps to reproduce 馃暪
Steps: See https://codesandbox.io/s/happy-sun-3v1d9x?file=/src/App.tsx
Context 馃敠
This issue occurs because Tooltip (and, perhaps, similar MUI components) require a ref to an HTML element, not a React class component.
Calling findDOMNode on
node
within useIsFocusVisible should work, but findDOMNode is deprecated.The solution for affected code is to forward the ref to the underlying DOM node, as described at https://thewebdev.info/2022/04/28/how-to-use-react-forwardref-in-a-class-based-component/.
Can/should useIsFocusVisible check for class components in development mode and throw a developer-friendly error message?
Your environment 馃寧
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: