title: React: Reload page only once if variable changes
body: <p>I have a variable <code>isVisible</code> that holds a boolean value. When this variable changes, I need to make a reload of the component, but only one time. And if the variable changes again at some point, then run this reload again for one time, but not continuously. Currently, I have this code that runs continuously:</p>
  <pre><code>useEffect(() =&gt; {
      if (isVisible) {
          window.location.reload();
      }
  }, [ isVisible ]);
  </code></pre>
  <p>How is this possible to achieve? Can someone tell me why this component is reloading continuously, even when I add the variable in dependency array?</p>