Last active
September 19, 2019 20:45
-
-
Save jeserodz/d4ece21f0cfe98778e260d560713a284 to your computer and use it in GitHub Desktop.
Routing utils for React Navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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