Я получаю сообщение об ошибке Unexpected key "characters" found in initialState argument passed to createStore. Expected to find one of the known reducer keys instead: "marvelReducer", "routing". Unexpected keys will be ignored.
rootReducer:
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
import marvelReducer from './marvelReducer';
const rootReducer = combineReducers({
marvelReducer,
routing: routerReducer
});
export default rootReducer;
marvelReducer:
import { FETCH_MARVEL } from '../constants/constants';
import objectAssign from 'object-assign';
export default function marvelReducer(state = [], action) {
switch (action.type) {
case FETCH_MARVEL:
return objectAssign({}, state, {characters: action.data});
default:
return state;
}
}
store:
import { createStore } from 'redux';
import { syncHistoryWithStore } from 'react-router-redux';
import { browserHistory } from 'react-router';
import rootReducer from '../reducers/index';
const initialState = {
characters: []
};
const store = createStore(rootReducer, initialState);
export const history = syncHistoryWithStore(browserHistory, store);
if (module.hot) {
module.hot.accept('../reducers/', () => {
const nextRootReducer = require('../reducers/index').default;
store.replaceReducer(nextRootReducer);
});
}
export default store;
У меня очень похожий код в другом приложении, и он работает нормально. Не уверен, что происходит здесь.