Unable to test this below code using @testing-library/react-native
useCallback(() => {
const onBackPress = () => {
Alert.alert("Hold on!", "Are you sure you want to Exit?", [
{
text: "Cancel",
onPress: () => null,
style: "cancel"
},
{ text: "YES", onPress: () => BackHandler.exitApp() }
]);
return true;
};
BackHandler.addEventListener("hardwareBackPress", onBackPress);
return () => BackHandler.removeEventListener("hardwareBackPress", onBackPress);
}, []));```