joealden / listed

A Curated List of Design Inspiration Resources.
https://listed.joealden.com/
MIT License
0 stars 0 forks source link

React.StrictMode Usage Results in findDOMNode Warning as styled-components uses it #11

Open joealden opened 6 years ago

joealden commented 6 years ago

Now that StrictMode has been enabled for the site, the following warning is logged to the console:

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of StyledComponent which is inside StrictMode. Instead, add a ref directly to the element you want to reference.

This is because as mentioned in https://github.com/styled-components/styled-components/issues/2154#issuecomment-434401222, there is no other suitable alternative to the findDOMNode method currently in React for styled-components' use case. The React team have said that they are thinking about implementing a solution for this unhandled use case (https://github.com/facebook/react/pull/13841#issuecomment-430066195).

For now, nothing can be done, as styled-components is waiting on React to implement a solution. This issue is here as a reference to explain why this error is logged to the console in dev mode.

joealden commented 5 years ago

An RFC for fragment refs has been created (https://github.com/reactjs/rfcs/pull/97).

If this RFC is approved, implement and merged, then it will likely give styled-components the ability to stop relying on findDOMNode in React versions that support the above feature.