模块react-router和react-router都有版本4.2.2 。以下是我的反应路线。
const history = syncHistoryWithStore(createBrowserHistory(), store);
const HeaderWithRouter = withRouter(Header);
ReactDOM.render(
<Provider store = {store}>
<Router history = {history} >
<section>
<HeaderWithRouter/>
<Route from = '/' to = '/deals'/>
<Route exact path="/deals" component={DealList}/>
<Route path = "/deal" component={FormDeal}/>
<Route path = "/admin" component={Admin}/>
<Route path = "/mandate" component={Mandate}/>
<Footer/>
</section>
</Router>
</Provider>
,
document.getElementById('app'));
不起作用的是<Route from = '/' to = '/deals'/>
我也收到了这个警告 - Failed context type: The context
router.push is marked as required in
withRouter(t), but its value is
undefined .