Zamknij aplikację wyjściową React Native
import React, { BackHandler } from 'react-native';
BackHandler.exitApp();
Dropout Programmer
import React, { BackHandler } from 'react-native';
BackHandler.exitApp();
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.backPressed);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.backPressed);
}
backPressed = () => {
Alert.alert(
'Exit App',
'Do you want to exit?',
[
{text: 'No', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'Yes', onPress: () => BackHandler.exitApp()},
],
{ cancelable: false });
return true;
}