react router change routes programatically code example
Example: react router change route from function
import {withRouter} from 'react-router-dom';
this.props.history.push('route');
export default withRouter(your component name)
the react component should be wrapped with withRouter hoc
so that history will work