stamen / panorama-template

Template / boilerplate for using stamen/panorama components, in a tasty React/Redux/React-Router shell
ISC License
2 stars 1 forks source link

Are there any negative consequences to giving all components access to the entire state and all actions? #3

Open clhenrick opened 8 years ago

clhenrick commented 8 years ago

Does it matter that the React paradigm prefers the explicit passing of data to props and this method goes against it?

I'm also wondering about the efficiency of passing all state and all actions to every component? I suppose you can be more selective in what you pass by not passing the entire state and all actions, only the ones you need from a parent to a child via state.thingOne and action.someAction?

This may not be a big deal for a small app but what about larger ones? Are there any potential performance issues? Would it make it more difficult to debug a larger app?

If we go this route should we use the current structure @ericsoco has so awesomely created here, or should we use <Provider> from react-redux which uses react.context to pass store implicitly to child components. As noted in a comment this opens up having to use mapStateToProps(), connect(), mapDispatchToProps(), but this was the way I learned Redux with React.

ericsoco commented 8 years ago

My intuition here is that this is an optimization we'd make on a project-by-project basis -- that the setup I built into the template is fine for most projects but that project authors can optionally migrate to react-redux, and along with it Provider, mapStateToProps(), etc.

N.B. The concept of context within React seems to still be up in the air / unstable, so I avoided it. Also, the API of having to add contextTypes to each consuming class feels like annoying boilerplate to me, so I shied away from it. These comments have nothing to do with the rest of react-redux, though.