I'm using react-native-router-flux
for react-native navigation. I've 4 scene stack on my react-native app.
When the app first boots up on Home screen, clicking on back button exits the app as expected.
But when I navigate to any other screen and comes back to the home screen, the back button doesn't seem to work anymore.
Here is the code snippet:
onBackPress() {
if (Actions.state.index === 0) {
return false;
}
Actions.pop();
return true;
}
<Router backAndroidHandler={this.onBackPress}>
<Scene key="root">
<Scene key="home" initial component={HomeScreen} />
<Scene key="screen2" component={MainScreen} />
<Scene key="screen3" component={ScreenSec} />
</Scene>
</Router>
I navigate to the home screen by using Actions.pop();
in my components.
Any idea on how can I exit the app whenever I come back to home screen by navigation to other screens?
Thanks.