Skip to content

Readme: connect() should wrap Counter in example #29

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
Aug 7, 2015

Conversation

af
Copy link
Contributor

@af af commented Aug 7, 2015

New to the project, so it's possible I'm reading this wrong, but I think in this example connect() is wrapping the wrong component.

New to the project, so it's possible I'm reading this wrong, but I think in this example `connect()` is wrapping the wrong component.
@hartzis
Copy link

hartzis commented Aug 7, 2015

They way it is listed now in the readme seems to be correct.

Since you're "injecting" the state as props into CounterContainer. The CounterContainer now has access to the state from its this.props. Check out this example:

https://github.com/gaearon/redux/blob/master/examples/counter/containers/CounterApp.js

I know this is an old example, but look how connect passes state.counter as this.props.counter in the render function. CounterApp is essentially CounterContainer in this example.

Does this help to explain it at all?

@af
Copy link
Contributor Author

af commented Aug 7, 2015

Thanks for the feedback @hartzis. Perhaps the problem then is the import statements– Counter is imported but never used, while CounterContainer is not imported nor defined anywhere, but is then used as a function argument. At the least running the code as-is will give you a ReferenceError :)

@gaearon
Copy link
Contributor

gaearon commented Aug 7, 2015

@af is correct.

@hartzis Master is a bit outdated, I just released react-redux@0.5.0 so official examples will be updated later. The intermediate component isn't needed anymore! See also https://github.com/gaearon/react-redux/releases/tag/v0.5.0 release notes.

gaearon added a commit that referenced this pull request Aug 7, 2015
Readme: connect() should wrap Counter in example
@gaearon gaearon merged commit e2b2ebe into reduxjs:master Aug 7, 2015
@hartzis
Copy link

hartzis commented Aug 7, 2015

@gaearon That is awesome! I totally see that now.

@af Great catch!

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