You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've following the docs to setup custom back navigation for the Android hardware back button. I'm quite new to RNN so I'm not sure if this is actually a bug or some setup missing from the docs. If it turns out I'm just missing some configuration I'll be very happy to do a PR and amend the docs myself to make this more explicit.
Here is the Navigation setup from my index.js file:
Navigation.registerComponent('com.myApp.WelcomeScreen',()=>App);Navigation.registerComponent('com.myApp.Practice',()=>Practice);Navigation.registerComponent('com.myApp.PracticeSummary',()=>PracticeSummary,);Navigation.events().registerAppLaunchedListener(()=>{Navigation.setDefaultOptions({topBar: {visible: false,drawBehind: true,animate: false,},// Hardwarde back button setup as described in the docshardwareBackButton: {dismissModalOnPress: false,popStackOnPress: false,},});Navigation.setRoot({root: {stack: {children: [{component: {name: 'com.myApp.WelcomeScreen',},},],},},});});
Here is the component where the event is being handled:
classPracticeSummaryextendsReact.Component<Props>{navigationEventListener: EventSubscription;componentDidMount(){this.navigationEventListener=Navigation.events().bindComponent(this);}componentWillUnmount(){if(this.navigationEventListener){this.navigationEventListener.remove();}}navigationButtonPressed({buttonId}){// this is never logged when pressing the back buttonconsole.log('Navigation button pressed!');}render(){// ...render component here}}
What was the expected behaviour?
When I reach this screen and press the hardware back button in Android, the event is never fired. I know my logs are working fine because I can see the logs from anywhere else in the app. The hardware back button continues to work as normal.
I've searched through the web for better information about how to do this setup, or any known issues. I've found several recipes, some using class components and others functional components. What I'm sharing here is what I was able to do based on the available documentation. I tried other solutions as well but nothing seems to work.
Thanks so much for your patience.
Was it tested on latest react-native-navigation?
I have tested this issue on the latest react-native-navigation release and it still reproduces.
What happened?
Package versions:
I've following the docs to setup custom back navigation for the Android hardware back button. I'm quite new to RNN so I'm not sure if this is actually a bug or some setup missing from the docs. If it turns out I'm just missing some configuration I'll be very happy to do a PR and amend the docs myself to make this more explicit.
Here are the docs I'm following:
Here is the Navigation setup from my index.js file:
Here is the component where the event is being handled:
What was the expected behaviour?
When I reach this screen and press the hardware back button in Android, the event is never fired. I know my logs are working fine because I can see the logs from anywhere else in the app. The hardware back button continues to work as normal.
I've searched through the web for better information about how to do this setup, or any known issues. I've found several recipes, some using class components and others functional components. What I'm sharing here is what I was able to do based on the available documentation. I tried other solutions as well but nothing seems to work.
Thanks so much for your patience.
Was it tested on latest react-native-navigation?
Help us reproduce this issue!
You can see the actual branch with the code here: https://github.com/amypellegrini/mpapp/tree/react-navigation-issue
Just do the usual setup for any RN application and launch on Android.
Steps:
In what environment did this happen?
React Native Navigation version: 7.37.1
React Native version: 0.72.6
Has Fabric (React Native's new rendering system) enabled: No
Node version: 18.17.1
Device model: Galaxy S10
Android version: 12
The text was updated successfully, but these errors were encountered: