Redux 路由器版本 ^2.1.2
反应路由器版本: "react-router": "^3.0.0"
,历史版本:"history": "^4.3.0"
,
重现步骤
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose } from 'redux';
import { Router, browserHistory } from 'react-router';
import { reduxReactRouter, routerStateReducer, ReduxRouter } from 'redux-router';
import reduxThunk from 'redux-thunk';
import { createHistory } from 'history';
import rootReducer from './core/rootReducer';
import routes from './core/routes';
import * as axios from './utils/axios.js';
import { AUTH_USER } from './authentication/types';
const store = compose(applyMiddleware(reduxThunk),
reduxReactRouter({ routes, createHistory })
)(createStore)(rootReducer);
const token = localStorage.getItem('token');
if (token) {
store.dispatch({ type: AUTH_USER });
}
ReactDOM.render(
<Provider store={store}>
<ReduxRouter>
{routes}
</ReduxRouter>
</Provider>
, document.querySelector('.main')
);
它返回一个错误index.js:34416 Uncaught TypeError: createHistory is not a function(…)
有什么解决办法吗?
改成import { createHistory } from 'history';
之后import createHistory from 'history/createBrowserHistory';
错误变成Uncaught TypeError: history.getCurrentLocation is not a function
想法?