I have created a React Native App.
I am using BackHandler. https://facebook.github.io/react-native/docs/backhandler.html
I am facing one weird issue, when I am running my app using
react-native run-android
my back button is working as expected.
But when I am running using Android Studio, whenever I am clicking on back button on any screen, it is directly exiting the App.
I have checked, the bundle js file is generating properly.
Below is the code:
import {BackHandler} from 'react-native';
class App extends Component {
constructor(props) {
super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
}
componentWillMount(){
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
}
componentWillUnmount(){
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick(){
this.props.navigation.goBack(null);
return true;
}
}
EDIT: The issue is when the debugger is open, the back button is working, If not open, back button not working.