prevent an error upon pressing the back button on the splash screen

This commit is contained in:
Akinwale Ariwodola 2018-07-24 14:37:31 +01:00
parent e8a572032a
commit f8af04ba4b

View file

@ -128,6 +128,7 @@ class AppWithNavigationState extends React.Component {
const { dispatch, nav } = this.props; const { dispatch, nav } = this.props;
// There should be a better way to check this // There should be a better way to check this
if (nav.routes.length > 0) { if (nav.routes.length > 0) {
if (nav.routes[0].routes && nav.routes[0].routes.length > 0) {
const subRoutes = nav.routes[0].routes[0].routes; const subRoutes = nav.routes[0].routes[0].routes;
const lastRoute = subRoutes[subRoutes.length - 1]; const lastRoute = subRoutes[subRoutes.length - 1];
if (nav.routes[0].routes[0].index > 0 && if (nav.routes[0].routes[0].index > 0 &&
@ -135,6 +136,7 @@ class AppWithNavigationState extends React.Component {
dispatch(NavigationActions.back()); dispatch(NavigationActions.back());
return true; return true;
} }
}
if (nav.routes[0].routeName === 'Main') { if (nav.routes[0].routeName === 'Main') {
if (nav.routes[0].routes[0].routes[0].index > 0) { if (nav.routes[0].routes[0].routes[0].index > 0) {
dispatch(NavigationActions.back()); dispatch(NavigationActions.back());