Sharing State Between Redux Reducers - HedgeDoc
  1878 views
<center> # Sharing State Between Redux Reducers *Originally published 2016-02-18 on [labs.OddSlingers.com](https://labs.oddslingers.com/posts/Sharing-State-Between-Redux-Reducers.html).* </center> 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. ## Your options: - don’t use `combineReducers` (write your own that shares state/selector between two components) - use the `redux-thunk` middleware - pass pre-bound selectors to the store down through your components or `mapDispatchToProps` (as recommended by `reselect`) - use a global store like `window.store` and call `window.store.getState().myreducer.myvalue` to directly access state ## On Managing state hierarchy in general: <ul> <li><a href="http://stackoverflow.com/questions/34299460/how-to-handle-global-state-data-into-deeply-nested-components-in-redux">How to hand global state data into deeply nested components in redux?</a></li> <li><a href="http://stackoverflow.com/questions/33852704/should-i-put-all-components-state-in-the-store">Should I put all component state into the redux store? </a></li> <li><a href="http://stackoverflow.com/questions/33953739/how-to-reduce-nested-data-in-redux?rq=1">How to reduce nested data in redux?</a></li> </ul> <strong>Specifically on sharing state between reducers:</strong> <ul> <li><a href="http://stackoverflow.com/questions/34333979/accessing-other-parts-of-the-state-when-using-combined-reducers?rq=1">Accessing other parts of the state when using combined reducers</a></li> <li><a href="http://stackoverflow.com/questions/35375810/how-do-i-share-readonly-state-between-two-or-more-reducers">How do I share readonly state between several reducers?</a></li> <li><a href="http://stackoverflow.com/questions/34711512/sharing-data-between-two-redux-reducers-states">Sharing state between two redux reducers</a></li> <li><a href="http://stackoverflow.com/questions/35430389/redux-where-to-prepare-data">Redux: where to prepare shared data</a></li> <li><a href="http://stackoverflow.com/questions/33962774/how-to-compose-redux-reducers-with-dependent-state?lq=1">How to compose redux reducers with dependent state</a></li> <li><a href="http://stackoverflow.com/questions/35300419/redux-do-i-have-to-import-store-in-all-my-containers-if-i-want-to-have-access-t">Redux: do I have to import store in all my containers to access shared state?</a></li> <li><a href="http://stackoverflow.com/questions/33408151/redux-reducer-state-shape-design-for-dependent-state-slices?rq=1">Redux reducer state shape design for dependent state slices?</a></li> </ul> Related Documentation: <ul> <li><a href="http://redux.js.org/docs/basics/Reducers.html">Redux Docs: Reducers</a></li> <li><a href="http://redux.js.org/docs/api/combineReducers.html">Redux Docs: combineReducers</a></li> <li><a href="https://github.com/acdlite/reduce-reducers">github: reduce-reducers</a> (combineReducers wo/ forced namespacing)</li> <li><a href="https://egghead.io/lessons/javascript-redux-implementing-store-from-scratch?series=getting-started-with-redux">egghead.io lesson: implementing a redux store from scratch</a></li> </ul>



Recent posts:


Back to top