react 15.3.2是否与react-router v4兼容

时间:2018-01-21 19:15:31

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

我正在尝试将我的项目升级到react-routerv4,但在这样做的过程中我遇到了以下错误

TypeError: Cannot read property 'location' of undefined
    at new t (vendor.2fdc9470.js:1)
    at c._constructComponentWithoutOwner (vendor.2fdc9470.js:1)
    at c._constructComponent (vendor.2fdc9470.js:1)
    at c.mountComponent (vendor.2fdc9470.js:1)
    at Object.mountComponent (vendor.2fdc9470.js:1)
    at c.performInitialMount (vendor.2fdc9470.js:1)
    at c.mountComponent (vendor.2fdc9470.js:1)
    at Object.mountComponent (vendor.2fdc9470.js:1)
    at c.performInitialMount (vendor.2fdc9470.js:1)
    at c.mountComponent (vendor.2fdc9470.js:1)

我已经像这样写了我的ReactDOM.render

// index.js

import { ConnectedRouter } from "react-router-redux"
const store = configureStore({ app: { isMobile } }) 
const history = createHistory()
ReactDOM.render(
    <Provider store={store}>
      <ConnectedRouter history={history}>
        {routes}// these are the routes exported from routes.js
      </ConnectedRouter>
    </Provider>,
    document.getElementById("root")
  )

我的路线就是这样写的//routes.js     出口默认(                                     ) 这将在index.js文件中导出和使用

特定于该问题的模块具有以下提到的版本。

"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^5.0.0-alpha.9",
 "react": "~15.3.2",

我知道我不能在反应路由器4中使用browserhostory.push,需要更换,但为什么我在供应商包中看到错误。我的供应商包包含

vendor: [
      "react",
      "react-mdl",
      "react-router",
      "react-redux",
      "redux-form",
      "redux-saga",
      "redux-storage",
      "lodash",
      "moment",
    ],

我知道历史对象中有一些问题正在通过连接路由器传递,但无法解决它。任何帮助和指针都将受到赞赏。谢谢。

0 个答案:

没有答案