Skip to content

Commit 685839f

Browse files
committed
Address code review comments
1 parent b326b3e commit 685839f

File tree

12 files changed

+18
-203
lines changed

12 files changed

+18
-203
lines changed

sidebars.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

versioned_docs/version-7.x/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ There are 2 primary ways to configure the navigators:
127127

128128
### Static configuration
129129

130-
The static configuration API has reduced boilerplate and simplifies things such as TypeScript types and deep linking. If you're starting a new project or are new to React Navigation, this is the **recommended way** to set up your app.
130+
The static configuration API has reduced boilerplate and simplifies things such as TypeScript types and deep linking. If you're starting a new project or are new to React Navigation, this is the **recommended way** to set up your app. If you need more flexibility in the future, you can always mix and match with the dynamic configuration.
131131

132132
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=static) to start writing some code with the static API.
133133

134134
### Dynamic configuration
135135

136-
The dynamic configuration allows for more flexibility but requires more boilerplate and configuration.
136+
The dynamic configuration allows for more flexibility but requires more boilerplate and configuration (e.g. for deep links, typescript etc.).
137137

138138
To get started with dynamic configuration, first, we need to wrap your app in `NavigationContainer`. Usually, you'd do this in your entry file, such as `index.js` or `App.js`:
139139

versioned_docs/version-7.x/glossary-of-terms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This object can be accessed with the [`useNavigation`](use-navigation.md) hook.
6666

6767
For more details, see the ["Navigation object docs"](navigation-object.md).
6868

69-
The ["Route object reference"](route-object.md) section goes into more detail on this, describes workarounds, and provides more information on other properties available on `route` prop.
69+
The ["Route object reference"](route-object.md) section goes into more detail on this, describes workarounds, and provides more information on other properties available on `route` object.
7070

7171
## Route object
7272

versioned_docs/version-7.x/headers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The argument that is passed in to the `options` function is an object with the f
107107
- `navigation` - The [navigation object](navigation-object.md) for the screen.
108108
- `route` - The [route object](route-object.md) for the screen
109109

110-
We only needed the `route` prop in the above example but you may in some cases want to use `navigation` as well.
110+
We only needed the `route` object in the above example but you may in some cases want to use `navigation` as well.
111111

112112
## Updating `options` with `setOptions`
113113

@@ -193,7 +193,7 @@ There are a couple of things to notice here:
193193

194194
## Sharing common `options` across screens
195195

196-
It is common to want to configure the header in a similar way across many screens. For example, your company brand color might be red and so you want the header background color to be red and tint color to be white. Conveniently, these are the colors we're using in our running example, and you'll notice that when you navigate to the `DetailsScreen` the colors go back to the defaults. Wouldn't it be awful if we had to copy the `options` header style properties from `Home` to `Details`, and for every single screen we use in our app? Thankfully, we do not. We can instead move the configuration up to the native stack navigator under `screenOptions`:
196+
It is common to want to configure the header in a similar way across many screens. For example, your company brand color might be red and so you want the header background color to be red and the tint color to be white. Conveniently, these are the colors we're using in our running example, and you'll notice that when you navigate to the `DetailsScreen` the colors go back to the defaults. Wouldn't it be awful if we had to copy the `options` header style properties from `Home` to `Details`, and for every single screen we use in our app? Thankfully, we do not. We can instead move the configuration up to the native stack navigator under `screenOptions`:
197197

198198
<Tabs groupId="config" queryString="config">
199199
<TabItem value="static" label="Static" default>

versioned_docs/version-7.x/navigation-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Profile extends React.Component {
9393
}
9494
```
9595

96-
One thing to keep in mind is that you can only listen to events from the immediate navigator with `addListener`. For example, if you try to add a listener in a screen that's inside a stack that's nested in a tab, it won't get the `tabPress` event. If you need to listen to an event from a parent navigator, you may use [`navigation.getParent`](navigation-object.md#getparent) to get a reference to parent screen's navigation object and add a listener.
96+
One thing to keep in mind is that you can only listen to events from the immediate navigator with `addListener`. For example, if you try to add a listener in a screen that's inside a stack that's nested in a tab, it won't get the `tabPress` event. If you need to listen to an event from a parent navigator, you may use [`navigation.getParent`](navigation-object.md#getparent) to get a reference to the parent screen's navigation object and add a listener.
9797

9898
```js
9999
const unsubscribe = navigation

versioned_docs/version-7.x/nesting-navigators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ If you want to achieve this behavior, see the guide for [screen options with nes
108108

109109
### Each screen in a navigator has its own params
110110

111-
For example, any `params` passed to a screen in a nested navigator are in the `route` prop of that screen and aren't accessible from a screen in a parent or child navigator.
111+
For example, any `params` passed to a screen in a nested navigator are in the `route` object of that screen and aren't accessible from a screen in a parent or child navigator.
112112

113113
If you need to access params of the parent screen from a child screen, you can use [React Context](https://reactjs.org/docs/context.html) to expose params to children.
114114

versioned_docs/version-7.x/route-object.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Route object reference
44
sidebar_label: Route object
55
---
66

7-
Each `screen` component in your app is provided with the `route` prop automatically. The prop contains various information regarding current route (place in navigation hierarchy component lives).
7+
Each `screen` component in your app is provided with the `route` object as a prop automatically. The prop contains various information regarding current route (place in navigation hierarchy component lives).
88

99
- `route`
1010
- `key` - Unique key of the screen. Created automatically or added while navigating to this screen.

versioned_docs/version-7.x/screen-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can pass a prop named `options` to the `Screen` component to configure a scr
3131
</Stack.Navigator>
3232
```
3333

34-
You can also pass a function to `options`. The function will receive the [`navigation` object](navigation-object.md) and the [`route` prop](route-object.md) for that screen. This can be useful if you want to perform navigation in your options:
34+
You can also pass a function to `options`. The function will receive the [`navigation` object](navigation-object.md) and the [`route` object](route-object.md) for that screen. This can be useful if you want to perform navigation in your options:
3535

3636
```js
3737
<Stack.Screen

versioned_docs/version-7.x/static-configuration.md

Lines changed: 0 additions & 181 deletions
This file was deleted.

versioned_docs/version-7.x/typescript.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The type containing the mappings must be a type alias (e.g. `type RootStackParam
6060

6161
### Type checking screens
6262

63-
To type check our screens, we need to annotate the `navigation` prop and the `route` prop received by a screen. The navigator packages in React Navigation export a generic types to define types for both the `navigation` and `route` props from the corresponding navigator.
63+
To type check 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.
6464

6565
For example, you can use `NativeStackScreenProps` for the Native Stack Navigator.
6666

@@ -120,7 +120,7 @@ type ProfileScreenNavigationProp = Props['navigation'];
120120
type ProfileScreenRouteProp = Props['route'];
121121
```
122122

123-
Alternatively, you can also annotate the `navigation` and `route` props separately.
123+
Alternatively, you can also annotate the `navigation` and `route` objects separately.
124124

125125
To get the type for the `navigation` prop, we need to import the corresponding type from the navigator. For example, `NativeStackNavigationProp` for `@react-navigation/native-stack`:
126126

@@ -135,7 +135,7 @@ type ProfileScreenNavigationProp = NativeStackNavigationProp<
135135

136136
Similarly, you can import `StackNavigationProp` from `@react-navigation/stack`, `DrawerNavigationProp` from `@react-navigation/drawer`, `BottomTabNavigationProp` from `@react-navigation/bottom-tabs` etc.
137137

138-
To get the type for the `route` prop, we need to use the `RouteProp` type from `@react-navigation/native`:
138+
To get the type for the `route` object, we need to use the `RouteProp` type from `@react-navigation/native`:
139139

140140
```tsx
141141
import type { RouteProp } from '@react-navigation/native';
@@ -231,11 +231,11 @@ const navigation = useNavigation<ProfileScreenNavigationProp>();
231231
:::danger
232232

233233
Annotating `useRoute` isn't type-safe because the type parameter cannot be statically verified.
234-
Prefer using the [`route` prop](route-object.md) instead when possible. Use `useRoute` for generic code that doesn't need specific route type.
234+
Prefer using the [`route` object](route-object.md) from the screen component's props instead when possible. Use `useRoute` for generic code that doesn't need specific route type.
235235

236236
:::
237237

238-
To annotate the `route` prop that we get from `useRoute`, we can use a type parameter:
238+
To annotate the `route` object that we get from `useRoute`, we can use a type parameter:
239239

240240
```ts
241241
const route = useRoute<ProfileScreenRouteProp>();
@@ -257,7 +257,7 @@ const options: StackNavigationOptions = {
257257

258258
Similarly, you can import `DrawerNavigationOptions` from `@react-navigation/drawer`, `BottomTabNavigationOptions` from `@react-navigation/bottom-tabs` etc.
259259

260-
When using the function form of `options` and `screenOptions`, you can annotate the arguments with the same type you used to annotate the `navigation` and `route` props.
260+
When using the function form of `options` and `screenOptions`, you can annotate the arguments with the same type you used to annotate the `navigation` and `route` objects from the [Type checking screens](#type-checking-screens) section.
261261

262262
### Annotating `ref` on `NavigationContainer`
263263

versioned_docs/version-7.x/use-route.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ title: useRoute
44
sidebar_label: useRoute
55
---
66

7-
`useRoute` is a hook which gives access to `route` object. It's useful when you cannot pass the `route` prop into the component directly, or don't want to pass it in case of a deeply nested child.
7+
`useRoute` is a hook which gives access to `route` object. It's useful when you cannot pass down the `route` object from props to the component, or don't want to pass it in case of a deeply nested child.
88

9-
`useRoute()` returns the `route` prop of the screen it's inside.
9+
`useRoute()` returns the `route` object of the screen it's inside.
1010

1111
## Example
1212

@@ -24,7 +24,7 @@ function MyText() {
2424
}
2525
```
2626

27-
See the documentation for the [`route` prop](route-object.md) for more info.
27+
See the documentation for the [`route` object](route-object.md) for more info.
2828

2929
## Using with class component
3030

versioned_sidebars/version-7.x-sidebars.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"upgrading-from-6.x"
4242
],
4343
"Static configuration": [
44-
"static-configuration",
4544
"static-api-reference",
4645
"static-typescript",
4746
"static-authentication",

0 commit comments

Comments
 (0)