Full single state atom not passed to reducers
Cina Saffary
Reducer composition greatly helps break up the concerns of an application into distinct units, but sometimes these reducers need to know something about a different part of the application state. It doesn't always make sense to combine these two reducers together just because they share this one interdependency. It would be helpful if the full
appState
atom was passed as an optional third argument to reducers for read-only purposes. Current workarounds include reading the needed value from getState() in the action creator and passing it along in the action, but this feels a bit polluting. I'd love to hear your take on this. Thanks!Daiwei Lu
What I usually do is to store smallest possible state in store. Then use selectors to calculate the states for components to use when connecting components. This eliminates the necessity to access other reduces' state when write reducer logic. I think this is where reselect (https://github.com/reactjs/reselect) shines.
Cina Saffary
Yeah, that occurred to me while watching the egghead videos, but I had already worked around the issue in a few places when I got bit by it.
Dan Abramov
Technically you can do this today by writing you root reducer by hand and passing the state atom. Does this help?