Reputation: 1956
I am very new to reactJs. I am trying to change the tab on click of button. For this I am using browserHistory
.
Problem here is url
is getting changed but component is not getting rendered.
Couldn't understand this.
browserHistory.push("/personalInfo");
This is how I am trying to change the tab.
Url is getting changed to http://localhost:3000/personalInfo
. But component is not rendered, when I refresh the browser, it's getting changed.
Upvotes: 0
Views: 1970
Reputation: 865
Use 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);
Upvotes: 1