import React from 'react';
import {render} from 'react-dom';
import { Router, Route, hashHistory } from 'react-router';
class App extends React.Component {
render() {
return (<h1>App</h1>);
}
}
render((
<Router history={hashHistory}>
<Route path="/" component={App}/>
</Router>
), document.getElementById('root'));
报错信息为
为什么已经引用了hashHistory却还会报错
react-router 更新到了4.0,很多API已经不一样了。history 被纳入了 react-router-dom 文件下的 HashRouter、BrowserRouter等。使用4.0版到react-router网站了解下新API,或者仍想按原来方式,可以安装旧版的react-router。
https://reacttraining.com/react-router/