-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect's wrapped component can't be a stateless function #141
Connect's wrapped component can't be a stateless function #141
Comments
You can suppress that warning by using troch/react-stateless as a workaround for now. What is the wrappedInstance ref used for? |
People use it for tests and side effects (i.e. calling instance methods) I presume. |
So is it okay to use stateless functions with React-Redux and I can ignore this warning? (I do not use ref or wrappedInstance). |
Yes, you can ignore the warning for now. |
Ok, thx :) |
This is fixed via 2d3d0be. |
Thanks! :) |
React 0.14 stateless components can't have refs, so this makes adding a `ref` to the wrapped component optional and **off by default**. This follows react-redux's implementation of `connect()`. See: reduxjs/react-redux#141
I ran into something that may be related. While using connect with a stateless component that had a child component with state (extends React.Component): the child component's If this is indeed an issue I would be happy to look into it and create a PR, I could also start a branch on the project to easily reproduce this (I've since removed the stateless component with connect). |
@mini-eggs : hmm. If it's something you can reproduce, please go ahead and file a new issue. |
If the component wrapped with
connect
is a stateless function component, React warns about the internal ref that the wrapper holds with the following messageWarning: Stateless function components cannot be given refs (See ref "wrappedInstance" in App created by Connect(App)). Attempts to access this ref will fail.
Would it be useful to check whether the component is stateless or not to decide when to apply the ref or do we always need it?
The text was updated successfully, but these errors were encountered: