title: React Native BackHandler not removing event Listener
body: <p>I am using React Navigation and I need some custom functionality when back button is pressed. Here is my code: </p>
  
  <pre><code>class AddEditIngredient extends Component {
    constructor(props) {
      super(props);
      this.state = {
        editStarted: false
      };
      this.goBack = () =&gt; {
        if (this.state.editStarted === true) {
          Alert.alert(
            "Ingredient Not Saved",
            "Do you want to navigate away without saving ingredient?",
            [
              { text: "Cancel", onPress: () =&gt; null, style: "cancel" },
              { text: "Yes", onPress: () =&gt; this.props.navigation.goBack() }
            ],
            { cancelable: true }
          );
        } else {
          this.props.navigation.goBack();
        }
      };
  }
  
  componentWillMount() {
      BackHandler.addEventListener("hardwareBackPress", this.goBack);
  }
  
  componentWillUnmount() {
      BackHandler.removeEventListener("hardwareBackPress", this.goBack);
  }
  </code></pre>
  
  <p>My goBack function works fine for back button on screen, however when I try to press the physical back button it pops out all the screens and minimizes the application. From what I have gathered by reading previous posts on the issue, removeEventListener is not referring to the same function as addEventListener. So I tried this:</p>
  
  <pre><code>constructor(props) {
      super(props);
      this.state = {
        editStarted: false
      };
      this.goBack = this.goBack.bind(this);
  }
  goBack = () =&gt; {
        if (this.state.editStarted === true) {
          Alert.alert(
            "Ingredient Not Saved",
            "Do you want to navigate away without saving ingredient?",
            [
              { text: "Cancel", onPress: () =&gt; null, style: "cancel" },
              { text: "Yes", onPress: () =&gt; this.props.navigation.goBack() }
            ],
            { cancelable: true }
          );
        } else {
          this.props.navigation.goBack();
        }
      };
  </code></pre>
  
  <p>But it didn't work. Can anyone point out my mistake?</p>
  
  <p>Thanks</p>