Material-table: Adding a custom render function to the Search icon causes two warnings in the console

Created on 29 May 2019  路  4Comments  路  Source: mbrn/material-table

Describe the bug
If I add a custom render function to the "Search" icon prop, two warnings will appear in the console.

To Reproduce
Steps to reproduce the behavior:

https://codesandbox.io/embed/blissful-sky-8w5th

Expected behavior
The console stays clear of errors.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: any
  • Browser any
bug

Most helpful comment

@Flixbox,

This is not a bug. Actually React.forwardRef required after mui4.0.0 upgrade. So if you change you icon usage like this it will be resolved:

icons={{
Search: React.forwardRef((props, ref) =>

)
}}

All 4 comments

Hi @Flixbox ,

Thanks for clear issue. I will take a look at this asap.

@Flixbox,

This is not a bug. Actually React.forwardRef required after mui4.0.0 upgrade. So if you change you icon usage like this it will be resolved:

icons={{
Search: React.forwardRef((props, ref) =>

)
}}

@mbrn I know this is not a bug, and the issue is closed - but I ran into this and could not fix it with your proposed solution. So I figured it may be valuable to give more detail on your fix.
I tried this (typescript):

import { Search } from '@material-ui/icons';

const SearchWithRef = React.forwardRef<SVGSVGElement, {}>((props, ref) => (
      <Search ref={ref} {...props} />
));

...

icons={{
     Search: () => <SearchWithRef />,
}}

But the error still shows up. Any idea what I did wrong? I thought this is your solution.

Can you try this:

import { Search } from '@material-ui/icons';

icons={{
     Search: React.forwardRef<SVGSVGElement, {}>((props, ref) => (
      <Search ref={ref} {...props} />
)),
}}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Likurg2010 picture Likurg2010  路  3Comments

kfirshahar picture kfirshahar  路  3Comments

Mihier-Roy picture Mihier-Roy  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments

bohrsty picture bohrsty  路  3Comments