-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Failed prop type: Invalid prop children
supplied to ForwardRef(Tooltip)
. Expected an element that can hold a ref
#31261
Comments
You are using |
If you wrap the children of the Tooltip to a fragment it doesn't generate an error
And there is no reference passed in fragments. That's not an expected behavior |
And because the tooltip component causes similar issues with disabled buttons wrapped-in, I created a wrapper to get around this problem. So the wrapper could be like:
Then place it in a temp-workaround folder and use it.
|
The disabled behavior is documented on the Tooltip page here. |
Perhaps the documentation should be changed to include the wrapper for all cases. In my code sample the button is enabled. |
Worked for me. |
Hi, |
Read more: mui/material-ui#31261
Still failing when u put any component inside |
Duplicates
Latest version
Current behavior 😯
Tooltip component emits an error on children reporting that a plain function component was used instead of a react element. But a react element was passed. Using a react fragment as a children wrapper is the current workaround
Sample here
https://codesandbox.io/s/compassionate-wave-59d138?file=/src/App.js
Error should show in console
Expected behavior 🤔
When a react component and a ref can be used in the tooltip's children no error should be emitted.
Steps to reproduce 🕹
Steps:
Setup a Tooltip component with your own react component as it's child for example
Examine the console's errors
Context 🔦
Also related with this issue
#15911
It's pretty much the same, so a common workaround could be made perhaps. Wrapping tooltip's children in a fragment gets rid of the error.
FYI @oliviertassinari
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: