title: Show modal window on click of tab close
body: <p>I am using react hook <code>useBeforeunload</code> to detect tab close event and want to display a modal window but I am stuck with below code. On click of close icon(X), it's not showing modal window which I am setting to true with setVisible and simply exiting the tab.</p>
  <pre><code>import { useBeforeunload } from 'react-beforeunload';
  
   const [visible, setVisible] = useState(false);
  
   const showModalWindow = (e) =&gt; {
    setVisible(true);
   }
  
  useBeforeunload((e) =&gt; {
      e.preventDefault();
      showModalWindow();
    });
  </code></pre>
  <p>Any suggestions to make this work will be really helpful. Thanks in advance :)</p>