title: How to access data from location in react-router-dom 6
body: <p>Working on a 'forgot password' functionality, I am trying to pass the email data from the 'login page' to the 'forgot password' page through Link.</p>
  <p>But when I am trying to access the same in the 'forgot password' page, it is giving me <em>undefined</em>.</p>
  <p>Could you please check my syntax?</p>
  <p>Below is the code-snippet and the code of the 'login page':</p>
  <pre><code>&lt;div className=&quot;forget-password-container&quot;&gt;
     &lt;div&gt;
         {&quot; &quot;}
         &lt;Link to={{
            pathname: &quot;/forget-password&quot;,
            state: formData.email,
         }}&gt;
            &lt;u style={{ textDecoration: &quot;underline&quot; }}&gt;Forgot Password&lt;/u&gt;
         &lt;/Link&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Forget Password Page:</p>
  <pre><code>const ForgetPassword = (props) =&gt; {
     // const { email } = (props.location &amp;&amp; props.location.state) || {};
     console.log(props?.location?.state);
     return &lt;div&gt;ForgetPassword &lt;/div&gt;;
   };
          
  export default ForgetPassword;
  </code></pre>
  <p>Please suggest to me how can I access the mail data on the 'forgot password' page</p>