title: react-router: beforeunload event not working for route change
body: <p>Here is my code:</p>
  
  <pre><code>constructor( props ) {
  super( props )
  this.state = {
    newOrganizationCountry            : ''
  }
  this.handleChange = this.handleChange.bind( this )
  this.handleSubmit = this.handleSubmit.bind( this )
  this.handleChangeOfTimeZone = this.handleChangeOfTimeZone.bind( this )    
  
  this.onUnload = this.onUnload.bind(this); // if you need to bind callback to this
      this.handleChangeOfStartDate = this.handleChangeOfStartDate.bind( this )
  { 
    /* 
    -&gt; Time Zone detail
    -&gt; https://raw.githubusercontent.com/yury-dymov/react-bootstrap-timezone-picker/master/src/timezones.json
    */ 
  }
  
  
  onUnload(event) { // the method that will be used for both add and remove event
    console.log("hellooww")
    event.returnValue = "Hellooww"
  }
  
  componentWillMount() {
        window.removeEventListener("beforeunload", this.onUnload)
  
  }
  
  
  componentDidMount() {
  if(this.state!=null){
        window.removeEventListener("beforeunload", this.onUnload)
      }
  }
  </code></pre>
  
  <p>This works when I close the window after changing something in the form and it asks me to confirm exit.
  But I want it to work when I click to another page/link/route.
  Please suggest me anything effective.
  Thanks</p>