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/nesting-navigators.md
+20-29Lines changed: 20 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -260,8 +260,6 @@ function App() {
260
260
}
261
261
```
262
262
263
-
When nesting multiple stack navigators, we recommend nesting at most 2 stack navigators, unless absolutely necessary to achieve the UI you want.
264
-
265
263
## Best practices when nesting
266
264
267
265
We recommend to reduce nesting navigators to minimal. Try to achieve the behavior you want with as little nesting as possible. Nesting has many downsides:
@@ -270,34 +268,27 @@ We recommend to reduce nesting navigators to minimal. Try to achieve the behavio
270
268
- Nesting same type of navigators (e.g. tabs inside tabs, drawer inside drawer etc.) might lead to a confusing UX
271
269
- With excessive nesting, code becomes difficult to follow when navigating to nested screens, configuring deep link etc.
272
270
273
-
Think of nesting navigators as a way to achieve the UI you want rather than a way to organize your code. If you want to create separate group of screens for organization, instead of using separate navigators, consider doing something like this:
271
+
Think of nesting navigators as a way to achieve the UI you want rather than a way to organize your code. If you want to create separate group of screens for organization, instead of using separate navigators, you can use the [`Group`](group.md) component.
274
272
275
273
```js
276
-
// Define multiple groups of screens in objects like this
277
-
constcommonScreens= {
278
-
Help: HelpScreen,
279
-
};
280
-
281
-
constauthScreens= {
282
-
SignIn: SignInScreen,
283
-
SignUp: SignUpScreen,
284
-
};
285
-
286
-
constuserScreens= {
287
-
Home: HomeScreen,
288
-
Profile: ProfileScreen,
289
-
};
290
-
291
-
// Then use them in your components by looping over the object and creating screen configs
292
-
// You could extract this logic to a utility function and reuse it to simplify your code
293
274
<Stack.Navigator>
294
-
{Object.entries({
295
-
// Use the screens normally
296
-
...commonScreens,
297
-
// Use some screens conditionally based on some condition
0 commit comments