You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We also know that `createStackNavigator` and related functions return React components. So when we set the `navigationOptions` directly on the `HomeStack` and `SettingsStack` component, it allows us to control the `navigationOptions` for its parent navigator when its used as a screen component. In this case, the `navigationOptions` on our stack components configure the label in the tab navigator that renders the stacks.
85
85
86
-
## **Caution**: the navigationOptions property vs configuration
87
-
88
-
Navigators are initialized with `create*Navigator(routeConfig, navigatorConfig)`. Inside of `navigatorConfig` we can add a `defaultNavigationOptions` property. These `defaultNavigationOptions` are the default options for screens within that navigator ([read more about sharing common navigationOptions](headers.html#sharing-common-navigationoptions-across-screens)), they do not refer to the `navigationOptions` for that navigator — as we have seen above, we set the `navigationOptions` property directly on the navigator for that use case.
89
-
90
86
```js
91
87
constHomeStack=createStackNavigator({ A }, {
92
88
// This is the default for screens in the stack, so `A` will
We understand that overloading the naming here is a little bit confusing. Please [open a RFC](https://github.com/react-navigation/rfcs) if you have a suggestion about how we can make this API easier to learn and work with.
102
+
Another way you could write this is:
103
+
104
+
```js
105
+
constHomeStack=createStackNavigator({ A }, {
106
+
// This applies to the parent navigator
107
+
navigationOptions: {
108
+
tabBarLabel:'Home!',
109
+
},
110
+
// This applies to child routes
111
+
defaultNavigationOptions: {
112
+
title:'Welcome'
113
+
}
114
+
});
115
+
```
116
+
117
+
<ahref="https://snack.expo.io/@react-navigation/nested-navigationoptions-title-v3"target="blank"class="run-code-button">→ Run this code</a>
118
+
119
+
# getActiveChildNavigationOptions
120
+
121
+
If you would like to get the `navigationOptions` from the active child of a navigator, you can do that with `getActiveChildNavigationOptions`. This makes it possible for you to set the `tabBarLabel` directly on a screen inside of a stack that is inside of a tab, for example.
// put other navigationOptions that you don't want the active child to
140
+
// be able to override here!
141
+
})
142
+
});
143
+
```
144
+
145
+
<ahref="https://snack.expo.io/@react-navigation/nested-navigationoptions-active-child-v3"target="blank"class="run-code-button">→ Run this code</a>
146
+
147
+
# **Note**: the navigationOptions property vs navigator configuration
148
+
149
+
Navigators are initialized with `create*Navigator(routeConfig, navigatorConfig)`. Inside of `navigatorConfig` we can add a `defaultNavigationOptions` property. These `defaultNavigationOptions` are the default options for screens within that navigator ([read more about sharing common navigationOptions](headers.html#sharing-common-navigationoptions-across-screens)), they do not refer to the `navigationOptions` for that navigator — as we have seen above, we set the `navigationOptions` property directly on the navigator for that use case.
150
+
107
151
108
152
# A stack contains a tab navigator and you want to set the title on the stack header
We also know that `createStackNavigator` and related functions return React components. So when we set the `navigationOptions` directly on the `HomeStack` and `SettingsStack` component, it allows us to control the `navigationOptions` for its parent navigator when its used as a screen component. In this case, the `navigationOptions` on our stack components configure the label in the tab navigator that renders the stacks.
86
86
87
-
## **Caution**: the navigationOptions property vs configuration
88
-
89
-
Navigators are initialized with `create*Navigator(routeConfig, navigatorConfig)`. Inside of `navigatorConfig` we can add a `defaultNavigationOptions` property. These `defaultNavigationOptions` are the default options for screens within that navigator ([read more about sharing common navigationOptions](headers.html#sharing-common-navigationoptions-across-screens)), they do not refer to the `navigationOptions` for that navigator — as we have seen above, we set the `navigationOptions` property directly on the navigator for that use case.
90
-
91
87
```js
92
88
constHomeStack=createStackNavigator({ A }, {
93
89
// This is the default for screens in the stack, so `A` will
We understand that overloading the naming here is a little bit confusing. Please [open a RFC](https://github.com/react-navigation/rfcs) if you have a suggestion about how we can make this API easier to learn and work with.
103
+
Another way you could write this is:
104
+
105
+
```js
106
+
constHomeStack=createStackNavigator({ A }, {
107
+
// This applies to the parent navigator
108
+
navigationOptions: {
109
+
tabBarLabel:'Home!',
110
+
},
111
+
// This applies to child routes
112
+
defaultNavigationOptions: {
113
+
title:'Welcome'
114
+
}
115
+
});
116
+
```
117
+
118
+
<ahref="https://snack.expo.io/@react-navigation/nested-navigationoptions-title-v3"target="blank"class="run-code-button">→ Run this code</a>
119
+
120
+
# getActiveChildNavigationOptions
121
+
122
+
If you would like to get the `navigationOptions` from the active child of a navigator, you can do that with `getActiveChildNavigationOptions`. This makes it possible for you to set the `tabBarLabel` directly on a screen inside of a stack that is inside of a tab, for example.
// put other navigationOptions that you don't want the active child to
141
+
// be able to override here!
142
+
})
143
+
});
144
+
```
145
+
146
+
<ahref="https://snack.expo.io/@react-navigation/nested-navigationoptions-active-child-v3"target="blank"class="run-code-button">→ Run this code</a>
147
+
148
+
# **Note**: the navigationOptions property vs navigator configuration
149
+
150
+
Navigators are initialized with `create*Navigator(routeConfig, navigatorConfig)`. Inside of `navigatorConfig` we can add a `defaultNavigationOptions` property. These `defaultNavigationOptions` are the default options for screens within that navigator ([read more about sharing common navigationOptions](headers.html#sharing-common-navigationoptions-across-screens)), they do not refer to the `navigationOptions` for that navigator — as we have seen above, we set the `navigationOptions` property directly on the navigator for that use case.
151
+
108
152
109
153
# A stack contains a tab navigator and you want to set the title on the stack header
0 commit comments