Skip to content

Instantly share code, notes, and snippets.

@jeserodz
Last active September 19, 2019 20:45
Show Gist options
  • Save jeserodz/d4ece21f0cfe98778e260d560713a284 to your computer and use it in GitHub Desktop.
Save jeserodz/d4ece21f0cfe98778e260d560713a284 to your computer and use it in GitHub Desktop.
Routing utils for React Navigation
/** Gets the current screen from navigation state */
function getActiveRouteName(navigationState) {
if (!navigationState) {
return null;
}
const route = navigationState.routes[navigationState.index];
// dive into nested navigators
if (route.routes) {
return getActiveRouteName(route);
}
return route.routeName;
}
export default {
getActiveRouteName,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment