title: Redirect in react-router-dom V6
body: <p>I need to navigate back to the original requested URL after login.</p>
  <p>For example, user enters <code>www.example.com/settings</code> as user is not authenticated, it will navigate to login page <code>www.example.com/login</code>.</p>
  <p>Once authenticated, it should navigate back to <code>www.example.com/settings</code> automatically.</p>
  <p>My original approach with <code>react-router-dom</code> v5 is quite simple:</p>
  <pre><code>const PrivateRoute = ({ isLoggedIn, component: Component, ...rest }) =&gt; {
    return (
      &lt;Route
        {...rest}
        render={(props) =&gt;
          isLoggedIn? (
            &lt;Component {...props} /&gt;
          ) : (
            &lt;Redirect
              to={{ pathname: `/login/${props.location.search}`, state: { from: props.location } }}
            /&gt;
          )
        }
      /&gt;
    );
  };
  
  
  &lt;PrivateRoute exact isLoggedIn={isLoggedIn} path=&quot;/settings&quot; component={Settings} /&gt;
  
  </code></pre>
  <p>Can some one tell me how to do that in v6? Thanks in advance</p>