【问题标题】:history.transitionTo is not a function, created by history/createBrowserHistoryhistory.transitionTo 不是函数,由 history/createBrowserHistory 创建
【发布时间】:2018-04-12 12:59:06
【问题描述】:

尝试使用 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()
});

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

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

我在哪里可以得到适合这个任务的历史对象?

感谢您的帮助!

【问题讨论】:

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


    【解决方案1】:

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

    npm i react-router-redux@next --save-dev
    

    【讨论】:

      猜你喜欢
      • 2019-08-23
      • 2022-11-23
      • 2018-09-06
      • 2019-06-27
      • 2018-04-25
      • 2021-12-14
      • 2018-10-31
      • 2019-10-05
      • 2017-12-12
      相关资源
      最近更新 更多