Skip to content

Instantly share code, notes, and snippets.

@rimiti

rimiti/index.js

Created Jun 9, 2018
Embed
What would you like to do?
Retrieving routeName from react-navigation state (redux implementation)
/**
* @description Returns current route name.
* @param routes
* @returns {string}
*/
getRouteNameFromNavigatorState ({ routes }) {
let route = routes[routes.length - 1];
while (route.index !== undefined) route = route.routes[route.index];
return route.routeName;
}
console.log(getRouteNameFromNavigatorState(this.props.nav));
// UserProfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.