Migrate from findDOMNode to refs
See original GitHub issueReact team just finally announced deprecating findDOMNode
.
https://github.com/facebook/react/pull/13841
Would be good to start providing better refs in each component to get rid from RootRef
.
Edit @eps1lon: Hijacking OP to document progress.
If we need the DOM node we still use findDOMNode
but we call it with refs. If the refs are attached to host components you won’t get a strict mode warning. Only if they are attached to class components.
Strict-mode ready findDOMNode
- Slider
- ButtonBase
- ClickAwayListener
- MenuList
- Modal
- Popover
- Portal
- ~[ ] RootRef~ compat module
- Slide
- SwipeableDrawer
- TextField
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Migrate React.findDOMNode to refs when rendering children
I'm dealing with a React component that uses React.findDOMNode(this) to obtain data about its position in the DOM, then it renders its ...
Read more >Migrate from findDOMNode to refs #13221 - mui/material-ui
I believe this would be a breaking change. The API allows in many cases that users pass a custom root component. We still...
Read more >Getting rid of findDOMNode in your React application - Medium
The simplest solution is to replace it with a ref attached to the element we are interested in referencing (or a wrapper of...
Read more >Refs and the DOM - React
Refs provide a way to access DOM nodes or React elements created in the render ... with useImperativeHandle ), or you can convert...
Read more >How to Use React.findDOMNode in TypeScript - Pluralsight
Simply attaching a ref callback to a particular DOM node should get you through all your required DOM manipulations smoothly. findDOMNode is ...
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 FreeTop 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
Top GitHub Comments
This is such a big move from React. For a long time, I thought they weren’t going to execute on this. From what I understand, the motivation is around simplifying React internal core. This makes sense. Let’s see how we can fulfill this new constraint.
Yes. Just reducing the amount of breaking changes.
At least for now. We’re still waiting for an official confirmation but so far
findDOMNode
doesn’t throw if called with host instances.