Failed prop type: Invalid prop `children` supplied to `ForwardRef(Tooltip)`. Expected an element that can hold a ref
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the 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
https://github.com/mui/material-ui/issues/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`
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Tooltip component and reproduce the warning using the linked CodeSandbox with a custom React component as its child. Trace the child ref validation and compare it with the fragment workaround. Done means a ref-capable React child produces no console prop-type error without requiring a fragment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100