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
Copy file name to clipboardExpand all lines: versioned_docs/version-6.x/navigation-container.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -571,6 +571,14 @@ Custom theme to use for the navigation components such as the header, tab bar et
571
571
572
572
### `independent`
573
573
574
-
Whether this navigation container should be independent of parent containers. Ifthis is not set to `true`, this container cannot be nested inside another container. Setting it to `true` disconnects any children navigators from parent container.
574
+
:::warning
575
+
576
+
This is an advanced use case. Don't use this unless you are 100% sure that you need it.
577
+
578
+
:::
579
+
580
+
Whether this navigation container should be independent of parent containers. If this is not set to `true`, this container cannot be nested inside another container. Setting it to `true` disconnects any children navigators from the parent container and doesn't allow navigation between them.
575
581
576
582
You probably don't want to set this to `true` in a typical React Native app. This is only useful if you have navigation trees that work like their own mini-apps and don't need to navigate to the screens outside of them.
583
+
584
+
Avoid using thisif you need to integrate with third-party components such as modals or bottom sheets. Consider using a [custom navigator](custom-navigators.md) instead.
@@ -155,9 +156,7 @@ Prop that accepts initial state for the navigator. This can be useful for cases
155
156
Example:
156
157
157
158
```js
158
-
<NavigationContainer
159
-
initialState={initialState}
160
-
>
159
+
<NavigationContainer initialState={initialState}>
161
160
{/* ... */}
162
161
</NavigationContainer>
163
162
```
@@ -417,7 +416,7 @@ import messaging from '@react-native-firebase/messaging';
417
416
}}
418
417
>
419
418
{/* content */}
420
-
</NavigationContainer>
419
+
</NavigationContainer>;
421
420
```
422
421
423
422
This option is not available on Web.
@@ -469,7 +468,7 @@ import messaging from '@react-native-firebase/messaging';
469
468
}}
470
469
>
471
470
{/* content */}
472
-
</NavigationContainer>
471
+
</NavigationContainer>;
473
472
```
474
473
475
474
This option is not available on Web.
@@ -569,8 +568,52 @@ function App() {
569
568
570
569
Custom theme to use for the navigation components such as the header, tab bar etc. See [theming guide](themes.md) for more details and usage guide.
571
570
572
-
### `independent`
571
+
### `navigationInChildEnabled`
572
+
573
+
:::warning
574
+
575
+
This prop exists for backward compatibility reasons. It's not recommended to use it in new projects. It will be removed in a future release.
576
+
577
+
:::
578
+
579
+
In previous versions of React Navigation, it was possible to navigate to a screen in a nested navigator without specifying the name of the parent screen, i.e. `navigation.navigate(ScreenName)` instead of `navigation.navigate(ParentScreenName, { screen: ScreenName })`.
580
+
581
+
However, it has a few issues:
582
+
583
+
- It only works if the navigator is already mounted - making navigation coupled to other logic.
584
+
- It doesn't work with the TypeScript types.
585
+
586
+
The `navigationInChildEnabled` prop allows you to opt-in to this behavior to make it easier to migrate legacy code. It's disabled by default.
587
+
588
+
For new code, see [navigating to a screen in a nested navigator](nesting-navigators.md#navigating-to-a-screen-in-a-nested-navigator) instead.
589
+
590
+
## Independent navigation containers
591
+
592
+
:::warning
593
+
594
+
This is an advanced use case. Don't use this unless you are 100% sure that you need it.
595
+
596
+
:::
597
+
598
+
In most apps, there will be only a single `NavigationContainer`. Nesting multiple `NavigationContainer`s will throw an error. However, in rare cases, it may be useful to have multiple independent navigation trees, e.g. including a mini-app inside a larger app.
599
+
600
+
You can wrap the nested `NavigationContainer`with the `NavigationIndependentTree` component to make it independent from the parent navigation tree:
Whetherthisnavigation container should be independent of parent containers. Ifthis is not set to `true`, thiscontainer cannot be nested inside another container. Setting it to `true` disconnects any children navigators from parent container.
617
+
Doingthisdisconnects any children navigators from the parent container and doesn't allow navigation between them.
575
618
576
-
You probably don't want to set this to `true` in a typical React Native app. This is only useful if you have navigation trees that work like their own mini-apps and don't need to navigate to the screens outside of them.
619
+
Avoid using this if you need to integrate with third-party components such as modals or bottom sheets. Consider using a [custom navigator](custom-navigators.md) instead.
0 commit comments