I have splash screen on my apps, so I want to exit the apps when we click android back button from the main page (not go back to splash screen). So I want to implement this method from react-native tutorial.
if (!this.onMainScreen()) {
this.goBack();
return true;
}
return false;
Is there anyone can help me how to implement onMainScreen(), and goBack() functions? Thank you for the help.
you should be able to use this function
pass it your navigation state and access the
routeName
member on the resulting object:let screenName = getCurrentRouteFromState(state).routeName
then you can compare the screen name with your main screen name and decide what to do.