class App extends React.Component {
constructor(props) {
super(props);
this.onGoBack = this.onGoBack.bind(this);
}
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.onGoBack);
}
componentWillUnmount() {
BackHandler.removeEventListener("hardwareBackPress", this.onGoBack);
}
onGoBack = () => {
Alert.alert("jiifwff");
console.log("ahbjhavf");
ToastAndroid.show("Back button is pressed", ToastAndroid.SHORT);
return true;
};
}