Skip to content

Commit

Permalink
Merge pull request #334 from backbonelabs/navigator-null-bug
Browse files Browse the repository at this point in the history
added null check for navigator
  • Loading branch information
kevhuang authored Jul 12, 2017
2 parents 6b7f363 + 654756a commit 3689795
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions app/containers/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ class Application extends Component {
return true;
}

const routeStack = this.navigator.getCurrentRoutes();
const currentRoute = routeStack[routeStack.length - 1];
if (currentRoute.name === routes.postureMonitor.name) {
// Delegate to the PostureMonitor to handle this scenario
return true;
if (this.navigator) {
const routeStack = this.navigator.getCurrentRoutes();
const currentRoute = routeStack[routeStack.length - 1];
if (currentRoute.name === routes.postureMonitor.name) {
// Delegate to the PostureMonitor to handle this scenario
return true;
} else if (this.navigator.getCurrentRoutes().length > 1) {
// There are subsequent routes after the initial route,
// so pop the route stack to navigate one scene back
this.navigator.pop();
return true;
}
}

if (this.navigator && this.navigator.getCurrentRoutes().length > 1) {
// There are subsequent routes after the initial route,
// so pop the route stack to navigate one scene back
this.navigator.pop();
return true;
}
// There are no routes to pop, exit app
return false;
});
Expand Down

0 comments on commit 3689795

Please sign in to comment.