connection function is the key to understand react-redux,
and it's complicated.
I am wondering why the author doesn't provide detailed information to explain the implementation of connection function, at least embed a few comments in the sourcecode.
If its too hard for newcomers to learn, they will turn to other frameworks like vue
@zhangk2000 : Are you more concerned about the _use_ of connect, or its implementation?
For usage, the basic approach is described in the Redux docs at http://redux.js.org/docs/basics/UsageWithReact.html , and the API docs are at https://github.com/reactjs/react-redux/blob/master/docs/api.md . There's also numerous tutorials online that describe how to use connect.
For implementation, to some extent that's supposed to be something that users don't have to worry about. In fact, the upcoming React Redux v5 version completely changes the internal implementation, without changing the public API at all. That said, Dan wrote a gist that shows the basic idea of what connect does, at https://gist.github.com/gaearon/1d19088790e70ac32ea636c025ba424e . There was also a video where Dan walked through the current (v4) version of connect and explains it, at https://youtu.be/VJ38wSFbM3A .The v5 implementation is described in #407 and #416.
Do you have any specific questions or concerns about the docs?
In addition to what @markerikson said, there's also more comments in the new version, currently in the next git branch. I tried to add comments to the stuff that is not-obvious, but what's obvious to one person, won't be the same was what's obvious to another. If there's specific areas of the code that you feel need greater explanation, please point them out.
Thanks @markerikson & @jimbolla
I have two questions about the wrappedcomponent generated by connect function, .
these concepts should be clarified in the introductory, or people will get confused.
I still say it'd be nice to have the React-Redux docs published in a more static form like Redux's. (But it's not a high enough priority to actually make it on my todo list atm.)
I think we just more prominent linkage from this repo to the docs in Redux. I don't want to get too crazy with the docs here, outside of really good reference documentation.
Yeah, given that we now have some more examples in there thanks to @jimbolla , I can live with that.
Most helpful comment
@zhangk2000 : Are you more concerned about the _use_ of
connect, or its implementation?For usage, the basic approach is described in the Redux docs at http://redux.js.org/docs/basics/UsageWithReact.html , and the API docs are at https://github.com/reactjs/react-redux/blob/master/docs/api.md . There's also numerous tutorials online that describe how to use
connect.For implementation, to some extent that's supposed to be something that users don't have to worry about. In fact, the upcoming React Redux v5 version completely changes the internal implementation, without changing the public API at all. That said, Dan wrote a gist that shows the basic idea of what
connectdoes, at https://gist.github.com/gaearon/1d19088790e70ac32ea636c025ba424e . There was also a video where Dan walked through the current (v4) version ofconnectand explains it, at https://youtu.be/VJ38wSFbM3A .The v5 implementation is described in #407 and #416.Do you have any specific questions or concerns about the docs?