title: How to redirect to a new page from a function in React?
body: <p>Right now I have this function in react and I am using it to go back to login and also to check reset the localStorage value for which I am using the function and not  since using that I cannot reset local storage value. The function is below:-</p>
  
  <pre><code>logout(){
      localStorage.clear();
      console.log("cliasdk");
      return(
          &lt;Redirect to="/login"/&gt;
      )
    }
  </code></pre>
  
  <p>This gets executed on clicking a div but I am not able to go to the /login page.How to do it?</p>