Skip to content

Commit c8feb2f

Browse files
committed
Document merge argument for navigate and popTo
1 parent 84334ca commit c8feb2f

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ Navigates back to a previous screen in the stack by popping screens after it. Th
10161016

10171017
- `name` - _string_ - Name of the route to navigate to.
10181018
- `params` - _object_ - Screen params to pass to the destination route.
1019+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
10191020

10201021
If a matching screen is not found in the stack, this will pop the current screen and add a new screen with the specified name and params.
10211022

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The `navigate` action allows to navigate to a specific route. It takes the follo
2828

2929
- `name` - _string_ - A destination name of the screen in the current or a parent navigator.
3030
- `params` - _object_ - Params to use for the destination route.
31+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
3132

3233
<Tabs groupId="config" queryString="config">
3334
<TabItem value="static" label="Static" default>
@@ -283,13 +284,20 @@ In a stack navigator ([stack](stack-navigator.md) or [native stack](native-stack
283284
- If you're on a different screen, it will push the new screen onto the stack.
284285
- If the [`getId`](screen.md#id) prop is specified, and another screen in the stack has the same ID, it will navigate to that screen and update its params instead.
285286
287+
<details>
288+
<summary>Advanced usage</summary>
289+
286290
The `navigate` action can also accepts an object as the argument with the following properties:
287291
288292
- `name` - _string_ - A destination name of the screen in the current or a parent navigator
289293
- `params` - _object_ - Params to use for the destination route.
290-
- `merge` - _boolean_ - Whether we should merge the params of the current route with the provided `params`. Defaults to `false`.
294+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
291295
- `path` - _string_ - The path (from deep link or universal link) to associate with the screen.
292296
297+
This is primarily used internally to associate a path with a screen when it's from a URL.
298+
299+
</details>
300+
293301
### reset
294302
295303
The `reset` action allows to reset the [navigation state](navigation-state.md) to the given state. It takes the following arguments:

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ The `navigate` method lets us navigate to another screen in your app. It takes t
7474

7575
`navigation.navigate(name, params)`
7676

77-
- `name` - A destination name of the route that has been defined somewhere
78-
- `params` - Params to pass to the destination route.
77+
- `name` - _string_ - A destination name of the screen in the current or a parent navigator.
78+
- `params` - _object_ - Params to use for the destination route.
79+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
7980

8081
<Tabs groupId="config" queryString="config">
8182
<TabItem value="static" label="Static" default>
@@ -297,8 +298,8 @@ It takes the following arguments:
297298

298299
`navigation.navigateDeprecated(name, params)`
299300

300-
- `name` - A destination name of the route that has been defined somewhere
301-
- `params` - Params to pass to the destination route.
301+
- `name` - _string_ - A destination name of the screen in the current or a parent navigator.
302+
- `params` - _object_ - Params to use for the destination route.
302303

303304
In a stack navigator ([stack](stack-navigator.md) or [native stack](native-stack-navigator.md)), calling `navigate` with a screen name will have the following behavior:
304305

versioned_docs/version-7.x/stack-actions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ The method accepts the following arguments:
534534

535535
- `name` - _string_ - Name of the route to navigate to.
536536
- `params` - _object_ - Screen params to pass to the destination route.
537+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
537538

538539
```js
539540
import { StackActions } from '@react-navigation/native';

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ Navigates back to a previous screen in the stack by popping screens after it. Th
588588
- `name` - _string_ - Name of the route to navigate to.
589589
- `params` - _object_ - Screen params to pass to the destination route.
590590

591+
- `name` - _string_ - Name of the route to navigate to.
592+
- `params` - _object_ - Screen params to pass to the destination route.
593+
- `merge` - _boolean_ - Whether params should be merged with the existing route params, or replace them (when navigating to an existing screen). Defaults to `false`.
594+
591595
If a matching screen is not found in the stack, this will pop the current screen and add a new screen with the specified name and params.
592596

593597
```js

0 commit comments

Comments
 (0)