Skip to content
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

lack of documentation #510

Closed
CellOcean opened this issue Oct 4, 2016 · 7 comments
Closed

lack of documentation #510

CellOcean opened this issue Oct 4, 2016 · 7 comments

Comments

@CellOcean
Copy link

CellOcean commented Oct 4, 2016

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

@markerikson
Copy link
Contributor

markerikson commented Oct 4, 2016

@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?

@jimbolla
Copy link
Contributor

jimbolla commented Oct 4, 2016

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.

@CellOcean
Copy link
Author

Thanks @markerikson & @jimbolla

I have two questions about the wrappedcomponent generated by connect function, .

  1. the state of every wrappedcomponent is the whole state tree ?
  2. trigger re-rendering of wrappedcomponent based on the state selected in mapstattoprops()?

these concepts should be clarified in the introductory, or people will get confused.

@jimbolla
Copy link
Contributor

jimbolla commented Oct 4, 2016

  1. Yes, the state argument passed to mapStateToProps is the root of the state tree in the store.
  2. Yes, typically the component will rerender based on a new value produced by mapStateStateToProps. It's actually based on the output of mergeProps, but its default value will almost always produce a new value if mapStateToProps did.

@timdorr timdorr closed this as completed Oct 4, 2016
@markerikson
Copy link
Contributor

markerikson commented Oct 5, 2016

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.)

@timdorr
Copy link
Member

timdorr commented Oct 5, 2016

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.

@markerikson
Copy link
Contributor

Yeah, given that we now have some more examples in there thanks to @jimbolla , I can live with that.

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

No branches or pull requests

4 participants