To redirect the user you want to call push on the history object. To get the history object in a class component you can use the withRouter higher-order component, e.g.

class Login extends Component {
  render() {
    const { history } = this.props;

    return (
       <button onClick={() => history.push('foo')}>Login</button>

export const LoginWithRouter = withRouter(Login);


Related Query

More Query from same tag