react router pop code example
Example 1: useHistory goback
import {useHistory} from "react-router-dom";
const history = useHistory();
<button onClick={() => history.goBack()}>Go Back</button>
Example 2: this.props.history.location.push
props.history.push({ pathname: '/register', state: data_you_need_to_pass});
Example 3: props history
class Comp extends React.Component {
componentDidUpdate(prevProps) {
const locationChanged =
this.props.location !== prevProps.location;
const locationChanged =
this.props.history.location !== prevProps.history.location;
}
}
<Route component={Comp} />;