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/typescript.md
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,10 @@ import TabItem from '@theme/TabItem';
9
9
10
10
React Navigation can be configured to type-check screens and their params, as well as various other APIs using TypeScript. This provides better intelliSense and type safety when working with React Navigation.
11
11
12
+
:::note
13
+
React Navigation is designed to work with [`strict`](https://www.typescriptlang.org/tsconfig/#strict) mode in TypeScript. If you are not using `strict` mode, some things might not work as expected.
14
+
:::
15
+
12
16
<TabsgroupId="config"queryString="config">
13
17
<TabItemvalue="static"label="Static"default>
14
18
@@ -187,6 +191,12 @@ The type containing the mapping must be a type alias (e.g. `type RootStackParamL
187
191
188
192
:::
189
193
194
+
If you have an [`id`](./navigator.md#id) prop for your navigator, you will also need to pass it as a generic:
To typecheck our screens, we need to annotate the `navigation` and the `route` props received by a screen. The navigator packages in React Navigation export generic types to define types for both the `navigation` and `route` props from the corresponding navigator.
@@ -211,7 +221,7 @@ The type takes 3 generics:
211
221
- The name of the route the screen belongs to
212
222
- The ID of the navigator (optional)
213
223
214
-
If you have an `id` prop for your navigator, you can do:
224
+
If you have an [`id`](./navigator.md#id) prop for your navigator, you can do:
0 commit comments