title: React Router navigation using history push
body: <p>I am new to ReactJS. I stuck with React routing when i tried to navigate from one page to another page history.push('/newpage') is not working for me. Login service call success i want navigate to another page. </p>
  
  <p>I am using below version</p>
  
  <p>"react": "^16.13.1",
  "react-dom": "^16.13.1",
  "react-router-dom": "^5.2.0",</p>
  
  <pre><code>import React, { Component } from 'react';
  import { useHistory } from 'react-router-dom';
  import '../Login/Login.css';
  import {Auth} from '../../services/Api';
  // import { Redirect } from 'react-router-dom'
  class Login extends Component {
  
      constructor(props) {
          super(props)
          this.state = {
              userName: '',
              password: ''
          }
          this.changeEventReact = this.changeEventReact.bind(this);
          this.login = this.login.bind(this);
      }
      changeEventReact = (e) =&gt;{
          this.setState({[e.target.name]: e.target.value});
          // console.log(this.state);
      }
      login = e=&gt;{
          // console.log(this.state);
          Auth('login', this.state)
          .then((result)=&gt;{
              let responseJSON = result;
              if(responseJSON.data.id != ''){
                  console.log("Login success");
                  const history = useHistory();
                  let path = `/facilityRegister`; 
                  history.push(path);
              }else{
                  console.log('Login failed');
              }
          });
      }
  </code></pre>
  
  <p>We can use below three methods to do this</p>
  
  <pre><code>1. history.push('/facilityRegister')
  2. &lt;Redirect to='/facilityRegister'/&gt;
  3. window.location.href("/facilityRegister')
  </code></pre>
  
  <p>window.location.href is working as expected. But history.push and  is not working.</p>
  
  <p>Let me know what I missed.</p>