If my React Native app fails to connect to its backend, I show an Alert with an OK button. If this happens, there\'s no point in the app continuing to run, so I\'d like to s
This is how I've achieved it:
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
BackHandler.exitApp();
return true;
}