title: React JS React-router-dom Navigate not working
body: <p>I try to redirect the user after login in my React App, but Navigate won't work and i don't know why...</p>
  <p>Here is my code and thanks for your help</p>
  <pre><code>import React, { Component } from &quot;react&quot;;
  import {Route, Navigate} from 'react-router-dom';
  import Bouton from &quot;../components/Bouton&quot;;
  
  class Dallan extends Component{
      logout = () =&gt;{
          localStorage.removeItem('logged');
          return &lt;Navigate to= '/login' /&gt;;
      }
      render(){
          return(
              &lt;Bouton typeBtn = 'btn-danger' click={() =&gt; this.logout()}&gt;Deconnexion&lt;/Bouton&gt;
          )
      }
  }
  
  export default Dallan;
  </code></pre>
  <p>And in my App.js</p>
  <pre><code>
  function App() {
    let session = localStorage.getItem('logged');
    return (
      &lt;BrowserRouter&gt;
      &lt;Routes&gt;
      &lt;Route path=&quot;/&quot; element={session ? &lt;Navigate to=&quot;/dallan&quot; /&gt; : &lt;Login/&gt;} /&gt;
         &lt;Route path='/dallan' element={&lt;Dallan/&gt;}/&gt;
      &lt;/Routes&gt;
      &lt;/BrowserRouter&gt;
   
    );
  }
  
  export default App;
  </code></pre>