Reactjs Browser Tab Close Event
<p>Hi I want to know how to prompt a message on browser tab close.
I am using Reactjs.</p>

<pre><code>handleWindowClose(){
    alert("Alerted Browser Close");
},
componentDidMount: function() {
    window.addEventListener('onbeforeunload', this.handleWindowClose);
},

componentWillUnmount: function() {
    window.removeEventListener('onbeforeunload', this.handleWindowClose);
}
</code></pre>

<p>this is what I have tried adding to my react component.Please guide me on how to proceed further.</p>