title: React Error Message Persists even after Refreshing the page
body: <p>I am working on a project in React. In  the Register Page, I add all errors in a Message component. During development, whenever a React error occurs <em>(like Cannot read properties of undefined)</em>, the error message continues to be displayed in the component until I successfully register. I want the error message to disappear whenever I reload the page.</p>
  <p>I tried putting the below condition to get rid of the error message but it didn't work. I don't understand why the error message persists.</p>
  <pre><code>{error ? &lt;Message variant=&quot;danger&quot;&gt;{error}&lt;/Message&gt; : &quot;&quot;}
  </code></pre>
  <p>Edit: I am using redux, so the error is being returned by an API call.</p>
  <pre><code>  const userCreate = useSelector((state) =&gt; state.userCreate);
    const { error, success, loading } = userCreate;
  </code></pre>
  <p>After I return this error in the Message component, it isn't disappearing. Once I even had to clear localStorage to get rid of it. The error was <em>Cannot read properties of undefined, reading password</em>.</p>