title: Confirm/warn dialog on back
body: <p>Like in the web browser, we have onBeforeUnload (vs onUnload) to show a alert or some warning "there is unsaved data - are you sure you want to go back".</p>
  
  <p>I am trying to do the same. I couldn't find anything in the docs of react-navigation.</p>
  
  <p>I thought of doing something real hacky like this, but I don't know if its the right way:</p>
  
  <pre><code>import React, { Component } from 'react'
  import { StackNavigator } from 'react-navigation'
  
  
  export default function ConfirmBackStackNavigator(routes, options) {
      const StackNav = StackNavigator(routes, options);
  
      return class ConfirmBackStackNavigatorComponent extends Component {
          static router = StackNav.router;
  
          render() {
              const { state, goBack } = this.props.navigation;
  
              const nav = {
                  ...this.props.navigation,
                  goBack: () =&gt; {
                      showConfirmDialog()
                      .then(didConfirm =&gt; didConfirm &amp;&amp; goBack(state.key))
                  }
              };
              return ( &lt;StackNav navigation = {nav} /&gt; );
          }
      }
  }
  </code></pre>