Skip to content

subscribe moved from Connector constructor to componentDidMount #179

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

Merged
merged 1 commit into from
Jun 26, 2015

Conversation

mattybow
Copy link
Contributor

You shouldn't need to attach the Connector components to redux's setState call unless the component mounts which should only be on the browser side. This will provide more flexibility in the way people decide to do server rendering because componentDidMount is not called on the server.

@@ -38,10 +38,14 @@ export default function createConnector(React) {
constructor(props, context) {
super(props, context);

this.unsubscribe = context.redux.subscribe(::this.handleChange);
this.redux = context.redux;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to to this (see below)

@mattybow
Copy link
Contributor Author

ok, thanks makes sense, I've modified as suggested

@gaearon
Copy link
Contributor

gaearon commented Jun 25, 2015

Can you please add a unit test verifying this change, and then squash the commits into a single commit? Thanks.

access redux instance from this.context

test added
@mattybow
Copy link
Contributor Author

@gaearon added unit test and squashed, very new to this, forgive me. Let me know if I need to change anything

gaearon added a commit that referenced this pull request Jun 26, 2015
subscribe moved from Connector constructor to componentDidMount
@gaearon gaearon merged commit 3d0476a into reduxjs:master Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants