Failed propType for Tooltip
See original GitHub issueDescribe the bug Warning popping up in the console (on 1.39 and MUI 4.0.1):
Failed prop type: Invalid prop `children` supplied to `Tooltip`. Expected an element that can hold a ref. Did you accidentally use a plain function component for an element instead?
in Tooltip (created by WithStyles(Tooltip))
in WithStyles(Tooltip) (created by MTableToolbar)
in div (created by ForwardRef(InputAdornment))
in ForwardRef(InputAdornment) (created by Context.Consumer)
in WithFormControlContext(ForwardRef(InputAdornment)) (created by WithStyles(WithFormControlContext(ForwardRef(InputAdornment))))
in WithStyles(WithFormControlContext(ForwardRef(InputAdornment))) (created by MTableToolbar)
To Reproduce
Steps to reproduce the behavior: 1.
const tableIcons: Icons = {
Add: () => <AddBox />,
Check: () => <Check />,
Clear: () => <Clear />,
Delete: () => <DeleteOutline />,
DetailPanel: () => <ChevronRight />,
Edit: () => <Edit />,
Export: () => <SaveAlt />,
Filter: () => <FilterList />,
FirstPage: () => <FirstPage />,
LastPage: () => <LastPage />,
NextPage: () => <ChevronRight />,
PreviousPage: () => <ChevronLeft />,
ResetSearch: () => <Clear />,
Search: () => <Search />,
SortArrow: () => <ArrowUpward />,
ThirdStateCheck: () => <Remove />,
ViewColumn: () => <ViewColumn />
};
const [geoHoldings, setGeoHoldings] = React.useState(
toJS(viewModel.geoHoldings) // [{country: 'US', weight: 1}]
);
<MaterialTable
icons={tableIcons}
columns={[
{
title: "Market",
field: "market",
lookup: marketLookup,
emptyValue: "-"
},
{
title: "Region",
field: "region",
lookup: regionsLookup,
emptyValue: "-"
},
{
title: "Sub region",
field: "subRegion",
lookup: subRegionsLookup,
emptyValue: "-"
},
{
title: "Country",
field: "country",
lookup: countriesLookup,
emptyValue: "-"
},
{
title: "Weight",
field: "weight",
emptyValue: "0 %",
type: "numeric",
render: rowData => `${rowData.weight.toFixed(2)} %`
}
]}
data={geoHoldings}
/>
- Navigate to it
- See the error in the console
Expected behavior Not having the message showing up
Desktop (please complete the following information):
- OS: Mac
- Browser Chrome
- Version 74.0.3729.169
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:14
Top Results From Across the Web
Developers - Failed propType for Tooltip - - Bountysource
Describe the bug. Warning popping up in the console (on 1.39 and MUI 4.0.1): Failed prop type: Invalid prop `children` supplied to `Tooltip` ......
Read more >Warning: Failed prop type: Invalid prop `label` of type `object ...
It means you're providing the wrong type to the label prop. It only expects a string, but you're passing a react fragment. Change...
Read more >Don't Call PropTypes Warning - React
Once this happens, any code that calls these functions manually (that isn't stripped in production) will throw an error. Declaring PropTypes is still...
Read more >failed prop type: invalid prop `rows` of type `object` supplied to ...
When deep cloning some elements in a JSX tree with Tooltip being amongst them, the error "Failed prop type: Invalid prop children of...
Read more >2 Answers - OneCompiler
Getting Warning: Failed prop type: Invalid prop `children` supplied to `ForwardRef(Tooltip)`. Expected an element that can hold a ref.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I got the same error and tried adding
React.forwardRef(...)
as recommended but to no avail. I don’t know if the problem is in my implementation but I wasn’t able to fix it. I was able to clear the warning by wrapping the component inside the Tooltip with<span>
. Voila! Tooltip is working and no warning.Basically, material-ui <Tooltip> expects children to be an element as it is being referenced internally as refs. Now in our case , we are using :
<Tooltip title="test"> <FontAwesomeIcon icon={faMicrophone} /> </Tooltip>
FontAwesomeIcon is a functional component which is not expected.
Instead use :
<Tooltip title="test"> <span> <FontAwesomeIcon icon={faMicrophone} /> </span> </Tooltip>
This will not give any warning and tooltip will show