My app works fine before I start to combine my Redux reducers. But when I combine, the initialState and reducer keys get mixed up.
function flash(state = [], action) {
switch (action.type) {
case FLASH_MESSAGE_UPDATED:
return _.extend({}, state, { flash: action.flash })
default:
return state
}
}
function events(state = [], action) {
switch (action.type) {
case EVENTS_UPDATED:
return _.extend({}, state, { events: action.pathway_events })
default:
return state
}
}
export default combineReducers({
events,
flash
})
This results in broken functionality and a console error of:
Unexpected keys "one", "two" found in initialState argument passed to createStore. Expected to find one of the known reducer keys instead: "events", "flash". Unexpected keys will be ignored.
My initial state is passed in with the help of redux-thunk.
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducer from '../../reducers/event'
let initialState = {
one: globalData.one,
two: globalData.two,
events: globalData.events,
flash: globalData.flash
}
let createStoreWithMiddleware = applyMiddleware(thunk)(createStore)
let reduxStore = createStoreWithMiddleware(reducer, initialState);
React.render(
<Provider store={reduxStore}>
<EventListContainer />
</Provider>,
$('.events')[0]
)
How can I correctly combine reducers?