mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-12 17:31:06 +08:00
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:
committed by
Brent Vatne
parent
70a2c3b97c
commit
3ac5f412b7
5
src/react-navigation.js
vendored
5
src/react-navigation.js
vendored
@@ -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;
|
||||
},
|
||||
|
||||
9
src/utils/getActiveChildNavigationOptions.js
Normal file
9
src/utils/getActiveChildNavigationOptions.js
Normal 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;
|
||||
Reference in New Issue
Block a user