title: How to Redirect to another page in ReactJS when a IF condition is executed?
body: <p>I want to redirect to Dashboard.jsx if the username and password matches. How to do that ? I am new to ReactJS.</p>
  
  <p>in the If condition I want to add the redirect code to redirect another page.
  Pls response. In stackoverflow maximum are using without if condition so here is the difference.</p>
  
  <pre><code>var users={
  name:'bddebashis',
  password:'debashis111249'
  }
  
  class Home extends Component {
  
  
  constructor() {
      super();
      this.handleSubmit = this.handleSubmit.bind(this);
  }
  
  
   handleSubmit(event) {
      event.preventDefault();
      const data = new FormData(event.target);
  
      fetch('/api/form-submit-url', {
          method: 'POST',
          body: data,
      });
  
      if(data.get('usr')==users.name &amp;&amp; data.get('paswd')==users.password){
        &lt;Redirect to='./Dashboard';/&gt;
  
      }
    }
  </code></pre>