I have a React application built using Redux and Redux-Thunk. Everything works fine until I try to combine reducers in Redux docs .
For the original, functional gearbox
export default function bigReducer(state = { events: [], flash: [] }, action) { switch (action.type) { case EVENTS_UPDATED: return _.extend({}, state, { events: action.pathway_events }) case FLASH_MESSAGE_UPDATED: return _.extend({}, state, { flash: action.flash }) default: return state } }
When I try to create a compound gearbox
function flashReducer(state = { flash: [] }, action) { switch (action.type) { case FLASH_MESSAGE_UPDATED: return _.extend({}, state, { flash: action.flash }) default: return state } } function eventReducer(state = { events: [] }, action) { switch (action.type) { case EVENTS_UPDATED: return _.extend({}, state, { events: action.pathway_events }) default: return state } }
initial state and gears seem to mix
// logging the state var EventListContainer = connect((state) => { console.log(state) return { events: state.events })(React.createClass({ ... // returns the incorrect state
How can I combine gears with React and Redux?
steel source share