Skip to content

Commit df547bd

Browse files
committed
Use 'object' instead 'prop' termibology for navigation & route
1 parent 716ea0d commit df547bd

31 files changed

+87
-159
lines changed

versioned_docs/version-7.x/bottom-tab-navigator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The `Tab.Navigator` component accepts following props:
5353

5454
#### `id`
5555

56-
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-prop.md#getparent) to refer to this navigator in a child navigator.
56+
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-object.md#getparent) to refer to this navigator in a child navigator.
5757

5858
#### `initialRouteName`
5959

@@ -442,7 +442,7 @@ React.useEffect(() => {
442442

443443
### Helpers
444444

445-
The tab navigator adds the following methods to the navigation prop:
445+
The tab navigator adds the following methods to the navigation object:
446446

447447
#### `jumpTo`
448448

versioned_docs/version-7.x/connecting-navigation-prop.md

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The hook returns an object with following properties:
4040
- `navigation` - The navigation object containing various helper methods for the navigator to manipulate the [navigation state](navigation-state.md). This isn't the same as the navigation object for the screen and includes some helpers such as `emit` to emit events to the screens.
4141
- `descriptors` - This is an object containing descriptors for each route with the route keys as its properties. The descriptor for a route can be accessed by `descriptors[route.key]`. Each descriptor contains the following properties:
4242

43-
- `navigation` - The navigation prop for the screen. You don't need to pass this to the screen manually. But it's useful if we're rendering components outside the screen that need to receive `navigation` prop as well, such as a header component.
43+
- `navigation` - The navigation object for the screen. You don't need to pass this to the screen manually. But it's useful if we're rendering components outside the screen that need to receive `navigation` prop as well, such as a header component.
4444
- `options` - A getter which returns the options such as `title` for the screen if they are specified.
4545
- `render` - A function which can be used to render the actual screen. Calling `descriptors[route.key].render()` will return a React element containing the screen content. It's important to use this method to render a screen, otherwise any child navigators won't be connected to the navigation tree properly.
4646

versioned_docs/version-7.x/custom-routers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const MyTabRouter = options => {
182182
};
183183
```
184184

185-
Instead of writing a custom router to handle custom actions, you can [pass a function to `dispatch`](navigation-prop.md#dispatch) instead. It's cleaner and recommended instead of overriding routers.
185+
Instead of writing a custom router to handle custom actions, you can [pass a function to `dispatch`](navigation-object.md#dispatch) instead. It's cleaner and recommended instead of overriding routers.
186186

187187
### Blocking Navigation Actions
188188

versioned_docs/version-7.x/drawer-navigator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The `Drawer.Navigator` component accepts following props:
9191

9292
#### `id`
9393

94-
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-prop.md#getparent) to refer to this navigator in a child navigator.
94+
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-object.md#getparent) to refer to this navigator in a child navigator.
9595

9696
#### `initialRouteName`
9797

@@ -529,7 +529,7 @@ If you have custom drawer content, make sure to emit this event.
529529

530530
### Helpers
531531

532-
The drawer navigator adds the following methods to the navigation prop:
532+
The drawer navigator adds the following methods to the navigation object:
533533

534534
#### `openDrawer`
535535

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

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

130130
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.
131131

132-
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=static) to start writing some code with the Static API.
132+
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

@@ -154,4 +154,4 @@ In a typical React Native app, the `NavigationContainer` should be only used onc
154154

155155
:::
156156

157-
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=dynamic) to start writing some code with the Dynamic API.
157+
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=dynamic) to start writing some code with the dynamic API.

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

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -55,41 +55,32 @@ const StackNavigator = (
5555

5656
The suffix `Screen` in the component name is entirely optional, but a frequently used convention; we could call it `Michael` and this would work just the same.
5757

58-
We saw earlier that our screen components are provided with the `navigation` prop. It's important to note that _this only happens if the screen is rendered as a route by React Navigation_ (for example, in response to `navigation.navigate`). For example, if we render `DetailsScreen` as a child of `HomeScreen`, then `DetailsScreen` won't be provided with the `navigation` prop, and when you press the "Go to Details... again" button on the Home screen, the app will throw one of the quintessential JavaScript exceptions "undefined is not an object".
58+
## Navigation object
5959

60-
```js
61-
function HomeScreen() {
62-
return (
63-
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
64-
<Text>Home Screen</Text>
65-
<Button
66-
title="Go to Details"
67-
onPress={() => navigation.navigate('Details')}
68-
/>
69-
<DetailsScreen />
70-
</View>
71-
);
72-
}
73-
```
74-
75-
The ["Navigation prop reference"](navigation-prop.md) section goes into more detail on this, describes workarounds, and provides more information on other properties available on `navigation` prop.
76-
77-
## Navigation Prop
78-
79-
This prop will be passed to all screens, and it can be used for the following:
60+
The navigation object contains methods used for navigation. It contains methods such as:
8061

8162
- `dispatch` will send an action up to the router
8263
- `navigate`, `goBack`, etc are available to dispatch actions in a convenient way
8364

84-
Navigators can also accept a navigation prop, which they should get from the parent navigator, if there is one.
65+
This object can be accessed with the [`useNavigation`](use-navigation.md) hook. It's also passed as a prop to screens defined with the dynamic API.
8566

86-
For more details, see the ["Navigation prop document"](navigation-prop.md).
67+
For more details, see the ["Navigation object docs"](navigation-object.md).
8768

88-
The ["Route prop reference"](route-prop.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` prop.
8970

90-
## Route Prop
71+
## Route object
9172

92-
This prop will be passed to all screens. Contains information about current route i.e. `params`, `key` and `name`.
73+
This prop will be passed to all screens. Contains information about the current route i.e. `params`, `key` and `name`. It can also contain arbitrary params:
74+
75+
```js
76+
{
77+
key: 'B',
78+
name: 'Profile',
79+
params: { id: '123' }
80+
}
81+
```
82+
83+
For more details, see the ["Route object reference"](route-object.md).
9384

9485
## Navigation State
9586

@@ -110,18 +101,6 @@ For this navigation state, there are two routes (which may be tabs, or cards in
110101

111102
You can read more about the navigation state [here](navigation-state.md).
112103

113-
## Route
114-
115-
Each route is an object which contains a key to identify it, and a "name" to designate the type of route. It can also contain arbitrary params:
116-
117-
```js
118-
{
119-
key: 'B',
120-
name: 'Profile',
121-
params: { id: '123' }
122-
}
123-
```
124-
125104
## Header
126105

127106
Also known as navigation header, navigation bar, app bar, and probably many other things. This is the rectangle at the top of your screen that contains the back button and the title for your screen. The entire rectangle is often referred to as the header in React Navigation.

versioned_docs/version-7.x/group.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Options to configure how the screens inside the group get presented in the navig
4949
</Stack.Group>
5050
```
5151

52-
When you pass a function, it'll receive the [`route`](route-prop.md) and [`navigation`](navigation-prop.md):
52+
When you pass a function, it'll receive the [`route`](route-object.md) and [`navigation`](navigation-object.md):
5353

5454
```js
5555
<Stack.Group

versioned_docs/version-7.x/headers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ function StackScreen() {
5353

5454
The argument that is passed in to the `options` function is an object with the following properties:
5555

56-
- `navigation` - The [navigation prop](navigation-prop.md) for the screen.
57-
- `route` - The [route prop](route-prop.md) for the screen
56+
- `navigation` - The [navigation object](navigation-object.md) for the screen.
57+
- `route` - The [route object](route-object.md) for the screen
5858

5959
We only needed the `route` prop in the above example but you may in some cases want to use `navigation` as well.
6060

versioned_docs/version-7.x/material-top-tab-navigator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The `Tab.Navigator` component accepts following props:
7575

7676
#### `id`
7777

78-
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-prop.md#getparent) to refer to this navigator in a child navigator.
78+
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-object.md#getparent) to refer to this navigator in a child navigator.
7979

8080
#### `initialRouteName`
8181

@@ -408,7 +408,7 @@ React.useEffect(() => {
408408

409409
### Helpers
410410

411-
The tab navigator adds the following methods to the navigation prop:
411+
The tab navigator adds the following methods to the navigation object:
412412

413413
#### `jumpTo`
414414

versioned_docs/version-7.x/multiple-drawers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function App() {
6464
}
6565
```
6666

67-
But there is one problem. When we call `navigation.openDrawer()` in our `HomeScreen`, it always opens the left drawer. We don't have access to the right drawer via the `navigation` prop since it's not a navigator.
67+
But there is one problem. When we call `navigation.openDrawer()` in our `HomeScreen`, it always opens the left drawer. We don't have access to the right drawer via the `navigation` object since it's not a navigator.
6868

6969
To solve this, we need to use context API to pass down a function to control the right drawer:
7070

@@ -192,7 +192,7 @@ export default function App() {
192192

193193
But there is one problem. When we call `navigation.openDrawer()` in our `HomeScreen`, it always opens the left drawer since it's the immediate parent of the screen.
194194

195-
To solve this, we need to use [`navigation.getParent`](navigation-prop.md#getparent) to refer to the right drawer which is the parent of the left drawer. So our code would look like:
195+
To solve this, we need to use [`navigation.getParent`](navigation-object.md#getparent) to refer to the right drawer which is the parent of the left drawer. So our code would look like:
196196

197197
```js
198198
<Button onPress={() => navigation.openDrawer()} title="Open left drawer" />
@@ -282,4 +282,4 @@ Here, we are passing `"LeftDrawer"` and `"RightDrawer"` strings (you can use any
282282
- To have multiple drawers, you can use [`react-native-drawer-layout`](drawer-layout.md) directly in combination with a drawer navigator.
283283
- The [`drawerPosition`](drawer-layout.md#drawerposition) prop can be used to position the drawer on the right.
284284
- The methods to control the drawer can be passed down using context API when using [`react-native-drawer-layout`](drawer-layout.md).
285-
- When nesting multiple navigators, you can use [`navigation.getParent`](navigation-prop.md#getparent) in combination with the [`id` prop](drawer-navigator.md#id) to refer to the desired drawer.
285+
- When nesting multiple navigators, you can use [`navigation.getParent`](navigation-object.md#getparent) in combination with the [`id` prop](drawer-navigator.md#id) to refer to the desired drawer.

versioned_docs/version-7.x/native-stack-navigator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The `Stack.Navigator` component accepts following props:
4949

5050
#### `id`
5151

52-
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-prop.md#getparent) to refer to this navigator in a child navigator.
52+
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-object.md#getparent) to refer to this navigator in a child navigator.
5353

5454
#### `initialRouteName`
5555

@@ -650,7 +650,7 @@ React.useEffect(() => {
650650

651651
### Helpers
652652

653-
The nativestack navigator adds the following methods to the navigation prop:
653+
The nativestack navigator adds the following methods to the navigation object:
654654

655655
#### `replace`
656656

versioned_docs/version-7.x/navigating-without-navigation-prop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Navigating without the navigation prop
44
sidebar_label: Navigating without the navigation prop
55
---
66

7-
Sometimes you need to trigger a navigation action from places where you do not have access to the `navigation` prop, such as a Redux middleware. For such cases, you can dispatch navigation actions use a [`ref` on the navigation container](navigation-container.md#ref).
7+
Sometimes you need to trigger a navigation action from places where you do not have access to the `navigation` object, such as a Redux middleware. For such cases, you can dispatch navigation actions use a [`ref` on the navigation container](navigation-container.md#ref).
88

99
**Do not** use the `ref` if:
1010

versioned_docs/version-7.x/navigating.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Another way to write this would be:
2424
</a>
2525
```
2626

27-
We'll do something similar to the latter, but rather than using a `window.location` global, we'll use the `navigation` prop that is passed down to our screen components.
27+
We'll do something similar to the latter, but rather than using a `window.location` global, we'll use the `navigation` object that's accessible in our screen components.
2828

2929
## Navigating to a new screen
3030

@@ -55,7 +55,7 @@ function HomeScreen() {
5555

5656
Let's break this down:
5757

58-
- `navigation` - the `navigation` object is returned from the [`useNavigation`](use-navigation.md) hook (more about this later in ["The navigation prop in depth"](navigation-prop.md)).
58+
- `navigation` - the `navigation` object is returned from the [`useNavigation`](use-navigation.md) hook (more about this later in ["The navigation object in depth"](navigation-object.md)).
5959
- `navigate('Details')` - we call the `navigate` function (on the `navigation` object &mdash; naming is hard!) with the name of the route that we'd like to move the user to.
6060

6161
:::note
@@ -171,4 +171,4 @@ function DetailsScreen() {
171171
- We can call `navigation.push('RouteName')` as many times as we like and it will continue pushing routes.
172172
- The header bar will automatically show a back button, but you can programmatically go back by calling `navigation.goBack()`. On Android, the hardware back button just works as expected.
173173
- You can go back to an existing screen in the stack with `navigation.popTo('RouteName')`, and you can go back to the first screen in the stack with `navigation.popToTop()`.
174-
- The `navigation` prop is available to all screen components (components defined as screens in route configuration and rendered by React Navigation as a route).
174+
- The `navigation` object is available to all screen components with the [`useNavigation`](use-navigation.md) hook.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function App() {
3131

3232
## Ref
3333

34-
It's also possible to attach a [`ref`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs) to the container to get access to various helper methods, for example, dispatch navigation actions. This should be used in rare cases when you don't have access to the `navigation` prop, such as a Redux middleware.
34+
It's also possible to attach a [`ref`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs) to the container to get access to various helper methods, for example, dispatch navigation actions. This should be used in rare cases when you don't have access to the [`navigation` object](navigation-object.md), such as a Redux middleware.
3535

3636
Example:
3737

@@ -57,7 +57,7 @@ function App() {
5757

5858
If you're using a regular ref object, keep in mind that the ref may be initially `null` in some situations (such as when linking is enabled). To make sure that the ref is initialized, you can use the [`onReady`](#onready) callback to get notified when the navigation container finishes mounting.
5959

60-
See the [Navigating without the navigation prop](navigating-without-navigation-prop.md) guide for more details.
60+
See the [Navigating without the navigation prop](navigating-without-navigation-object.md) guide for more details.
6161

6262
### Methods on the ref
6363

@@ -77,7 +77,7 @@ In addition to these methods, the ref object also includes the following special
7777

7878
The `isReady` method returns a `boolean` indicating whether the navigation tree is ready. The navigation tree is ready when the `NavigationContainer` contains at least one navigator and all of the navigators have finished mounting.
7979

80-
This can be used to determine whether it's safe to dispatch navigation actions without getting an error. See [handling initialization](navigating-without-navigation-prop.md#handling-initialization) for more details.
80+
This can be used to determine whether it's safe to dispatch navigation actions without getting an error. See [handling initialization](navigating-without-navigation-object.md#handling-initialization) for more details.
8181

8282
#### `resetRoot`
8383

@@ -207,7 +207,7 @@ Example:
207207

208208
Function which is called after the navigation container and all its children finish mounting for the first time. You can use it for:
209209

210-
- Making sure that the `ref` is usable. See [docs regarding initialization of the ref](navigating-without-navigation-prop.md#handling-initialization) for more details.
210+
- Making sure that the `ref` is usable. See [docs regarding initialization of the ref](navigating-without-navigation-object.md#handling-initialization) for more details.
211211
- Hiding your native splash screen
212212

213213
Example:

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

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

7-
`NavigationContext` provides the `navigation` object (same object as the [navigation](navigation-prop.md) prop). In fact, [useNavigation](use-navigation.md) uses this context to get the `navigation` prop.
7+
`NavigationContext` provides the `navigation` object (same object as the [navigation](navigation-object.md) prop). In fact, [useNavigation](use-navigation.md) uses this context to get the `navigation` prop.
88

99
Most of the time, you won't use `NavigationContext` directly, as the provided `useNavigation` covers most use cases. But just in case you have something else in mind, `NavigationContext` is available for you to use.
1010

0 commit comments

Comments
 (0)