Mui-datatables: Function components cannot be given refs.

Created on 8 Jul 2019  路  5Comments  路  Source: gregnb/mui-datatables

My Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 4.1.2 |
| MUI-datatables | 2.6.1 |
| React | 16.8.6 |
| browser | chrome |
| etc | |

I have warning when I try to use mui-datatable in my project. like this:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? index.js:1375 

Check the render method of `WithStyles(Tooltip)`.
    in Tooltip (created by WithStyles(Tooltip))
    in WithStyles(Tooltip) (created by t)
    in t (created by t)
    in span (created by t)
    in div (created by t)
    in div (created by ForwardRef(Toolbar))
    in ForwardRef(Toolbar) (created by WithStyles(ForwardRef(Toolbar)))
    in WithStyles(ForwardRef(Toolbar)) (created by t)
    in t (created by t)
    in t (created by WithStyles(t))
    in WithStyles(t) (created by r)
    in r (created by t)
    in div (created by ForwardRef(Paper))
    in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
    in WithStyles(ForwardRef(Paper)) (created by t)
    in t (created by WithStyles(t))
    in WithStyles(t) (at ListView.jsx:19)
    in ListView (created by Context.Consumer)
    in Route (at Layout/index.jsx:17)
    in Switch (at Layout/index.jsx:14)
    in main (at Layout/index.jsx:52)
    in div (at Layout/index.jsx:40)
    in Layout (created by Context.Consumer)
    in Route (at App/index.js:13)
    in Router (at App/index.js:12)
    in App (at src/index.js:7)

Most helpful comment

If you don't need print functionality, just add print: false to options. You won't get that warning again

All 5 comments

Try reducing your material-ui version to 3.5.1. The latest is not yet supported by this library.

Tried removing tooltip from Toolbar component

I tried removing Tooltip component from Toolbar Component inside mui-datatables library. I found that react-to-print props trigger takes function component as input and we cannot forward ref there.

When i removed Tooltip everything was working fine. I didn't run test tough to check if anything else was breaking.

Tried removing tooltip from Toolbar component

I tried removing Tooltip component from Toolbar Component inside mui-datatables library. I found that react-to-print props trigger takes function component as input and we cannot forward ref there.

When i removed Tooltip everything was working fine. I didn't run test tough to check if anything else was breaking.

How to remove Tooltip please

If you don't need print functionality, just add print: false to options. You won't get that warning again

I think this was fixed by a round of improvements that enhance support for mui v4, so closing this unless the issue crops up again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhmmdakbr picture mhmmdakbr  路  4Comments

naothomachida picture naothomachida  路  3Comments

krsandesh picture krsandesh  路  3Comments

JordanKadish picture JordanKadish  路  4Comments

Aankhen picture Aankhen  路  3Comments