Open atomanyih opened 8 years ago
Thanks for this report. The ref
is used for the instance method getWrappedInstance()
, so I guess that method will not work for a stateless function component. Not sure what the solution is here, I'll leave this open and if anybody needs this method on a stateless function component they can look into it.
Just to clarify: this error means that the getWrappedInstance()
method will not work for stateless functional components, but everything else should continue to function as normal.
We should do what redux does and make this opt-in: https://github.com/reactjs/react-redux/commit/2d3d0beade55477b3af65534ceb793db18b25705
Would accept any pull-request that implements the same solution as the linked react-redux code.
Another approach would be to use a child function as react-virtualized/AutoSize is doing it (It's providing the same feature with a different API).
If you use
Dimensions
to wrap a stateless functional component it complains but still seems to work.will give
Warning: Stateless function components cannot be given refs (See ref "wrappedInstance" in SomebodyCaresAboutDimensions created by DimensionsHOC). Attempts to access this ref will fail.