Cannot read property 'push' of undefined react

import {Router} from 'react-router'

import createBrowserHistory from 'history/createBrowserHistory'

const history = createBrowserHistory();


const store = rehydrate();


const renderApp = Component => {

  render(


      <Router history={history}>

          <App/>

      </Router>,

    document.getElementById("root")

  );

};

这样写不是会直接注入history吗?
我在App里面用this.props.hist6ory.push()就报错!要从context里面取吗?

回首忆惘然
浏览 408回答 1
1回答

侃侃尔雅

import {withRouter} from 'react-router'import {inject, observer} from "mobx-react";@inject("store")@withRouter加个注解
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript