0
我有这个代码:路由器没有定义
import { Router, Route } from 'react-router'
render((
<Router>
<Route path="/" component={ App }>
<Route path="page1" component={ Page1 }/>
<Route path="page2" component={ Page2 }/>
<Route path="page3" component={ Page3 }/>
</Route>
</Router>
), document.getElementById('app-container'));
而且具有的WebPack编译它,babeljs后,谷歌浏览器显示错误:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
当我想通原因是路由器不作为'react-router'属性导出,因此Router组件是'undefined'
我使用react-router版本0.13.5。有什么方法可以正确使用它?
我试过react-router版本^ 1.0.0-rc1,现在相同的代码工作得很好。但我仍然困惑 – taydakov