@material-ui/core 4.0.0-beta.1 Warning: Function components cannot be given refs.
See original GitHub issueWhen using @material-ui/core
4.0.0-beta.1
& mui-datatables
2.0.0
I get the following warning:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `Tooltip`.
in ViewColumnIcon (created by Tooltip)
in Tooltip (created by WithStyles(Tooltip))
in WithStyles(Tooltip) (created by l)
in span (created by ForwardRef(IconButton))
in button (created by ButtonBase)
in ButtonBase (created by ForwardRef(ButtonBase))
in ForwardRef(ButtonBase) (created by WithStyles(ForwardRef(ButtonBase)))
in WithStyles(ForwardRef(ButtonBase)) (created by ForwardRef(IconButton))
in ForwardRef(IconButton) (created by WithStyles(ForwardRef(IconButton)))
in WithStyles(ForwardRef(IconButton)) (created by l)
in l (created by l)
in div (created by l)
in div (created by ForwardRef(Toolbar))
in ForwardRef(Toolbar) (created by WithStyles(ForwardRef(Toolbar)))
in WithStyles(ForwardRef(Toolbar)) (created by l)
in l (created by t)
in t (created by WithStyles(t))
in WithStyles(t) (created by t)
in t (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))
I suspect it has something to do with the fact that the MUI team has changed their components to be functional and use Hooks.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:25
- Comments:20 (2 by maintainers)
Top Results From Across the Web
React Warning: Function components cannot be given refs
What I am struggling to understand is why I get a Warning: Function components cannot be given refs. Attempts to access this ref...
Read more >functional components cannot be given refs - You.com | The AI ...
When using @material-ui/core 4.0.0-beta.1 & mui-datatables 2.0.0 I get the following warning: Warning: Function components cannot be given refs.
Read more >material-ui/core/CHANGELOG.md - UNPKG
This is a reminder that all ongoing work has moved to v5. This means a feature freeze on v4. The development of v4...
Read more >@material-ui/core | Yarn - Package Manager
React components for faster and simpler web development. Build your own design system, or start with Material Design. ... Installation. Material-UI is available ......
Read more >Composition - Material UI - MUI
Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?. Note that you will...
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
@pfarnach Yes, support for v4 is part of the plan. That’s not a bad idea about milestones and/or issues around upgrade necessities. Trying to review some PRs and fix some bugs at the moment, but when I get some time, I can start work on an upgrade roadmap.
I’ve recently had to add
material-ui
tooltips to functional components and looks like this does the trick:React.forwardRef(/* ... */)
ref: React.Ref<HTMLButtonElement>
)ref
above to the component included in the functional oneThe components that trigger the warning are the
mui-datatables
toolbar icons (Search, etc.).