Redux Combined Reducers - andrewkyllo-401-advanced-javascript/seattle-javascript-401d34 GitHub Wiki

Combined Reducers

  • Combined reducers are nothing more than pulling in more than one reducer from source and creating a keyed object from them
import todoReducer from './todo.store.js';
import itemReducer from './item.store.js';

let reducers = combineReducers({
  todo: todoReducer,
  item: itemReducer,
});

Once done, any component can reach into the store and get either one, both, or all

import * as actions from "../../store/todo.store.js";
import * as itemActions from "../../store/item.store.js";

const mapStateToProps = state => ({
  todo: state.todo,
  item: state.item,
});

const mapDispatchToProps = (dispatch, getState) => ({
  deleteItem: id => dispatch(actions.deleteItem(id)),
  hideDetails: id => dispatch(itemActions.hideDetails()),
});