Last active
November 2, 2019 14:16
-
-
Save ScreamZ/59f79b6530c647c87c957e7dabffe8f6 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Crawl through navigation state to get route metadata. | |
* | |
* @param {*} navigationState | |
* @returns {*} | |
*/ | |
export function getActiveRouteMetadata(navigationState) { | |
if (!navigationState) { | |
return null; | |
} | |
const route = navigationState.routes[navigationState.index]; | |
// Dive into nested navigators as long we haven't reach current screen. | |
if (route.routes) { | |
return getActiveRouteMetadata(route); | |
} | |
return route; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment