我尝试使用redux设置react和react-routers,react-redux具有以下存储初始化
import { createStore, applyMiddleware,compose } from 'redux';
import thunk from 'redux-thunk';
import {reduxReactRouter} from 'redux-router';
import { createHistory } from 'history';
import createLogger from 'redux-logger';
import rootReducer from './reducers';
import routes from './routes';
const loggerMiddleware = createLogger()
export default function configureStore(initialState) {
let createStoreWithMiddleware;
const logger = createLogger();
const middleware = applyMiddleware(thunk, logger);
createStoreWithMiddleware = compose(
middleware,
reduxReactRouter({routes, createHistory})
);
const store = createStoreWithMiddleware(createStore)(rootReducer, initialState);
if (module.hot) {
module.hot
.accept('./reducers', () => {
const nextRootReducer = require('./reducers/index');
store.replaceReducer(nextRootReducer);
});
}
return store;
}
我的应用程序是使用create-react-app创建的,在启动时我在控制台中遇到以下错误
TypeError: Cannot read property 'location' of undefined
如何调试?如何识别问题的根源?