I'm using react navigation v5 and I'm trying to make a default android back button handler inside routes.js. Using flux there was backAndroidHandler param which let you do this. My questios is there something i can use in navigation v5.
I know there is https://reactnavigation.org/docs/custom-android-back-button-handling/. But the problem is i don't want to go to every screen and set it.
Current solution is this:
useEffect(
useCallback(() => {
const onAndroidBack = () => {
};
BackHandler.addEventListener('hardwareBackPress', onAndroidBack);
return () =>
BackHandler.removeEventListener('hardwareBackPress', onAndroidBack);
}, [])
);
My question does navigation v5 have some kind of solution for this build in, like flux had? Is there a better way to manage android back button?