I'd like to prevent componentWillUnmount like beforeunload in React
<p>I'd like to do beforeunload with React, but I cannot.
For example</p>

<pre><code>window.addEventListener("beforeunload", function (e) {
  var confirmationMessage = "\o/";

  e.returnValue = confirmationMessage;     // Gecko and Trident
  return confirmationMessage;              // Gecko and WebKit
});
</code></pre>

<p>But, I wanna do as below</p>

<pre><code>componentWillUnmount: function(e) {
    var result = confirm('\o/');
    if (!result) {
       // prevent unmount
    }
},
</code></pre>