react router - Router.js:111Uncaught TypeError:无法读取属性' getCurrentLocation'未定义的

时间:2016-11-29 14:28:51

标签: node.js reactjs server react-router

我一直在按照本教程让React Router工作https://scotch.io/tutorials/routing-react-apps-the-complete-guide ...但是当我尝试使用反应路由器的任何功能时 - 它给了我这个:

  

Router.js:111Uncaught TypeError:无法读取属性   ' getCurrentLocation'未定义的       在Object.createTransitionManager(localhost:8080 / public / bundle.js:22730:14)       at Object.componentWillMount(localhost:8080 / public / bundle.js:22737:36)       在localhost:8080 / public / bundle.js:15709:24       at measureLifeCyclePerf(localhost:8080 / public / bundle.js:15436:13)       在ReactCompositeComponentWrapper.performInitialMount(localhost:8080 / public / bundle.js:15708:10)       在ReactCompositeComponentWrapper.mountComponent(localhost:8080 / public / bundle.js:15619:22)       在Object.mountComponent(localhost:8080 / public / bundle.js:8009:36)       在ReactCompositeComponentWrapper.performInitialMount(localhost:8080 / public / bundle.js:15732:35)       在ReactCompositeComponentWrapper.mountComponent(localhost:8080 / public / bundle.js:15619:22)       在Object.mountComponent(localhost:8080 / public / bundle.js:8009:36)

我也尝试过使用webpack-dev-server ......但仍然没有快乐 - 同样的问题。我无法找到任何其他提及此错误的信息......可能是什么问题?

spark.locality.wait

1 个答案:

答案 0 :(得分:0)

是的,我测试一下,你需要将history = {browserHistory}传递给你的路由器。

render(
    <Router history={ browserHistory }>
        <Route path="/" component={Home}/>
    </Router>,
    document.getElementById('container')
 );

并且不要忘记导入browserHistory:

import { Router, Route, browserHistory, Link, IndexRoute } from 'react-router';