失败的上下文类型:上下文`router.push`在`withRouter(t)`中标记为必需,但其值为`undefined`

时间:2017-09-12 04:53:46

标签: reactjs react-router react-router-dom

模块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 .

0 个答案:

没有答案