Introduce getActiveChildNavigationOptions (#5080)

This is a utility to allow navigationOptions definition functions to access the navigation options of the active child route, which allows people to replicate the v1 behavior of deep nav configuration.
This commit is contained in:
Eric Vicenti
2018-10-09 15:37:57 -07:00
committed by Brent Vatne
parent 70a2c3b97c
commit 3ac5f412b7
4 changed files with 947 additions and 21 deletions

View File

@@ -106,6 +106,11 @@ module.exports = {
get validateRouteConfigMap() {
return require('./routers/validateRouteConfigMap').default;
},
// Utils
get getActiveChildNavigationOptions() {
return require('./utils/getActiveChildNavigationOptions').default;
},
get pathUtils() {
return require('./routers/pathUtils').default;
},

View File

@@ -0,0 +1,9 @@
const getActiveChildNavigationOptions = (navigation, screenProps) => {
const { state, router, getChildNavigation } = navigation;
const activeRoute = state.routes[state.index];
const activeNavigation = getChildNavigation(activeRoute.key);
const options = router.getScreenOptions(activeNavigation, screenProps);
return options;
};
export default getActiveChildNavigationOptions;