How can I catch the other events that not in the on the screen in addition to onBackPress?
My goal is to bounce modal when a user presses the Android back button or other buttons that not in the screen (like header and tabs)
How do I catch the rest of the buttons events that the user presses and bounce modal?
useFocusEffect(
React.useCallback(() => {
const onBackPress = () => {
if (isnewArray != false ){
setAlertModalVisiblity(true);
return true
}else{
return false
}
};
BackHandler.addEventListener(
'hardwareBackPress', onBackPress
);
return () =>
BackHandler.removeEventListener(
'hardwareBackPress', onBackPress
);
}, [])
);