history.transitionTo不是由history / createBrowserHistory创建的函数

时间:2017-10-31 11:15:14

标签: reactjs redux react-redux react-router-v4 react-router-redux

尝试使用redux,immutable和react-redux-router创建应用程序。

二手包的版本:

"immutable": "^3.8.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^4.0.8",
"history": "^4.7.2",
"redux": "^3.7.2",
"redux-immutable": "^4.0.0"

我使用history npm包中的createSagaMiddleware函数创建历史记录。

import createHistory from 'history/createBrowserHistory';
const browserHistory: any = createHistory();

但是,如果我将历史记录的这个实例传递给syncHistoryWithStore函数,以便从商店中同步我的位置和状态

const history = syncHistoryWithStore(browserHistory, store, {
    selectLocationState: createSelectLocationState()
});

当我尝试导航到某个页面时出现以下错误:

enter image description here

因为我的历史对象没有transitionTo函数。

我在哪里可以获得适合此任务的History对象?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我认为,您应该更改react-router-redux的版本,因为“react-router-redux”:“^ 4.0.8”仅适用于react-router v3,但您使用react-router v4(反应 - 路由器-DOM)

npm i react-router-redux@next --save-dev
相关问题