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-7.x/static-combine-with-dynamic.md
+117Lines changed: 117 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,120 @@ id: static-combine-with-dynamic
3
3
title: Combining static and dynamic APIs
4
4
sidebar_label: Combining with dynamic API
5
5
---
6
+
7
+
While the static API has many advantages, it doesn't fit use cases where the navigation configuration needs to be dynamic. So React Navigation supports interop between the static and dynamic APIs.
8
+
9
+
Keep in mind that the features provided by the static API such as automatic linking configuration and automatic TypeScript types need the whole configuration to be static. If part of the configuration is dynamic, you'll need to handle those parts manually.
10
+
11
+
There are 2 ways you may want to combine the static and dynamic APIs:
- Linking configuration for the screens in the top tab navigator.
62
+
- TypeScript types for the screens in the top tab navigator.
63
+
64
+
Since the nested navigator is defined using the dynamic API, we need to handle these manually. For the linking configuration, we can define the screens in the `linking` property of the `Feed` screen:
Here the `screens` property is the same as how you'd define it with `linking` config with the dynamic API. It can contain configuration for any nested navigators as well. See [configuring links](configuring-links.md) for more details on the API.
89
+
90
+
For the TypeScript types, we can define the type of the `FeedScreen` component:
1. We first define the param list type for screens in the navigator that defines params for each screen
113
+
2. Then we use the `NavigatorScreenParams` type to get the type of route's `params` which will include types for the nested screens
114
+
3. Finally, we use the type of `params` with `StaticScreenProps` to define the type of the screen component
115
+
116
+
This is based on how we'd define the type for a screen with a nested navigator with the dynamic API. See [Type checking screens and params in nested navigator](typescript.md#type-checking-screens-and-params-in-nested-navigator).
0 commit comments