-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Stores not "composing"? #156
Comments
@levibotelho that behaviour is expected. What's going on behind the scenes is that each store's state is essentially held in a "big object" that holds every other state in redux. When you "slice" them through a selector you're gaining access to that object and your selection process starts from there. () I guess that the examples are still too shallow as to show the pattern at its full extent. For example, the todomvc container gets all todos, it so happens that the store is called *todos and that its reducer returns an array so it's very simple. I think we need larger examples to show this. I'll make sure to publish back our new code as it happens these days as it might be useful to a larger crowd :) EDIT: (*) Mixing every property of your stores in a huge bag of "things" mixed by your stores' results wouldn't be very handy as you would very quickly have clashes. |
As @dariocravero said, the stores are subdivided by the name of the store. It prevents conflicts in naming and allows you to know which store you are accessing. If you take a look at this https://github.com/gaearon/redux#smart-components , it shows the counter store property being accessed on the state. I definitely agree more documentation around selecting state is needed. |
ref #140 |
@dariocravero @taylorhakes Thank you both for the explanation. I agree that it makes total sense to split up the stores -- I was caught off guard by the todo project which indeed is so simple that it made me think I was missing something. Thanks again! |
:) |
Closing as not an issue. |
I'm having a bit of a hard time understanding the example provided on the main page in regards to stores.
I have two stores defined, each of which consists of a single function that returns an object. When creating my redux instance, I do the following:
So far so good, as far as I can tell.
My problem is that in the select method on one of my components, I attempt to read the store values as follows
However instead of containing
signedUpUser
andsignUpError
properties as I would expect,state
containsauthenticationStore
andsignUpStore
properties which contain the return values of their respective functions.By looking at the demo on the main page of the repo, I was under the impression that the results of my store functions would be composed into a single state object, and not subdivided by store. Am I doing something incorrectly, or is my understanding of stores/state flawed?
The text was updated successfully, but these errors were encountered: