title: Put A Warning If Page Refresh in ReactJS
body: <p>My problem is that I need the user to confirm if he wants to continue to refresh the page. If he press <code>No</code>, it won't refresh the page.</p>
  <p>Kindly take a look at my development so far:-</p>
  <pre><code>useEffect(() =&gt; {
      window.addEventListener(&quot;beforeunload&quot;, alertUser);
      return () =&gt; {
        window.removeEventListener(&quot;beforeunload&quot;, alertUser);
      };
    }, []);
  </code></pre>