When writing an app using Redux and React, you may run into the common problem of having to share state between multiple components in your app.
Don’t worry, you aren’t the first to have this problem, here are some resources to help you out.
- don’t use combineReducers (write your own that shares state/selector between two components)
- use thunk middleware
- pass selectors on global store through all your actions
- call window.store.getState().myreducer.myvalue directly to get the state (worst option)
On Managing state hierarchy in general:
- How to hand global state data into deeply nested components in redux?
- Should I put all component state into the redux store?
- How to reduce nested data in redux?
Specifically on sharing state between reducers:
- Accessing other parts of the state when using combined reducers
- How do I share readonly state between several reducers?
- Sharing state between two redux reducers
- Redux: where to prepare shared data
- How to compose redux reducers with dependent state
- Redux: do I have to import store in all my containers to access shared state?
- Redux reducer state shape design for dependent state slices?
- Redux Docs: Reducers
- Redux Docs: combineReducers
- github: reduce-reducers (combineReducers wo/ forced namespacing)
- egghead.io lesson: implementing a redux store from scratch