我对reactJs很陌生。我正在尝试在单击按钮时更改选项卡。为此,我正在使用browserHistory
.
这里的问题是url
正在更改,但组件未呈现。无法理解这一点。
browserHistory.push("/personalInfo");
这就是我尝试更改选项卡的方式。网址正在更改为http://localhost:3000/personalInfo
。但是组件没有呈现,当我刷新浏览器时,它正在发生变化。
使用withRouter
import React, { Component } from "react";
import {withRouter} from "react-router-dom";
class MyComponent extends Component {
sampleFunction() {
this.props.history.push("/personalInfo");
}
}
export default withRouter(MyComponent);