question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed propType for Tooltip

See original GitHub issue

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`. 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}
    />
  1. Navigate to it
  2. 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:14

github_iconTop GitHub Comments

40reactions
amendoza-micronsystemscommented, Feb 14, 2020

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.

36reactions
kapoorruchicommented, Jan 9, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found