Skip to content

Commit f2a79c2

Browse files
committed
Tweak wording for TypeScript setup
1 parent 68b98df commit f2a79c2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

versioned_docs/version-8.x/typescript.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,7 @@ There are 2 steps to configure TypeScript with the dynamic API:
348348

349349
### Specifying the root navigator's type {#specifying-the-root-navigators-type-dynamic}
350350

351-
You can specify the type for your root navigator which will enable automatic type inference for [`useRoute`](use-route.md), [`useNavigation`](use-navigation.md), [`useNavigationState`](use-navigation-state.md), [`Link`](link.md), [`ref`](navigation-container.md#ref), [`linking`](navigation-container.md#linking) etc.
352-
353-
To do this, use module augmentation for `@react-navigation/native` and extend the `RootNavigator` interface with the type of your root navigator.
351+
For the type-inference to work, React Navigation needs to know the type of the root navigator in your app. To do this, you can declare a module augmentation for `@react-navigation/native` and extend the `RootNavigator` interface with the type of your root navigator.
354352

355353
```ts
356354
type RootStackParamList = {
@@ -373,9 +371,11 @@ declare module '@react-navigation/native' {
373371

374372
Here `RootStack` refers to the navigator used at the root of your app. The `RootStackParamList` type is covered in the next section.
375373

374+
This is needed to type-check hooks such as [`useNavigation`](use-navigation.md), [`useRoute`](use-route.md), [`useNavigationState`](use-navigation-state.md) etc.
375+
376376
### Specifying param types for screens {#specifying-param-types-for-screens-dynamic}
377377

378-
To type check route names and params, create an object type with mappings from route names to the params of each route. For example, say we have a route called `Profile` in our root navigator which should have a param `userId`:
378+
To type check route names and params, we need to create an object type with mappings from route names to the params of each route. For example, say we have a route called `Profile` in our root navigator which should have a param `userId`:
379379

380380
```tsx
381381
type RootStackParamList = {
@@ -419,7 +419,7 @@ And then we can use it:
419419

420420
This will provide type checking and IntelliSense for props of the [`Navigator`](navigator.md) and [`Screen`](screen.md) components.
421421

422-
When a screen renders a nested navigator, use `NavigatorScreenParams` for that route. Define the child navigator first:
422+
When a screen renders a nested navigator, use `NavigatorScreenParams` for that route. First, define and export the child navigator object:
423423

424424
```ts title="navigation/HomeStack.tsx"
425425
import { createStackNavigator } from '@react-navigation/stack';

0 commit comments

Comments
 (0)