title: Detect browser reload in reactJS
body: <p>I'm trying to detect browser reload in my react application. I've looked around many solutions but no solution was right for me.</p>
  <p>What I want to do is detect browser reload from a specific page. Some of the solutions I tried were almost correct but the issue is it cannot differentiate the browser reload and normal navigation. For ex: the solutions I used could trigger when the browser is being reloaded. But they also trigger when I come to that page using router. What can I do to limit my solution to only trigger when the browser is being reloaded.</p>
  <p>The solutions I tried</p>
  <pre><code>  useEffect(()=&gt;{
      if (typeof window !== undefined) {
        if (window.performance) {
          if (performance.getEntriesByType(&quot;navigation&quot;)[0].type === 'reload') {
            alert('This page is reloaded');
          } else {
            alert('This page is not reloaded');
          }
        }
      }
    },[])
  </code></pre>
  <p>And</p>
  <pre><code>  useEffect(() =&gt; {
      console.log(&quot;AAAAAAA&quot;,window.performance.navigation)
    },[]);
  </code></pre>