Skip to content

Commit 107c0c1

Browse files
committed
Document navigateDeprecated
1 parent 3cd824e commit 107c0c1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ In a stack navigator ([stack](stack-navigator.md) or [native stack](native-stack
244244

245245
- If you're already on a screen with the same name, it will update its params and not push a new screen.
246246
- If you're on a different screen, it will push the new screen onto the stack.
247-
- If the [`getId`](screen.md#getid) prop is specified, and another screen in the stack has the same ID, it will navigate to that screen and update its params instead.
247+
- If the [`getId`](screen.md#getid) prop is specified, and another screen in the stack has the same ID, it will bring that screen to focus and update its params instead.
248+
- If none of the above conditions match, it'll push a new screen to the stack.
248249

249250
By default, the screen is identified by its name. But you can also customize it to take the params into account by using the [`getId`](screen.md#getid) prop.
250251

@@ -277,8 +278,11 @@ const Tabs = createBottomTabNavigator({
277278

278279
</TabItem>
279280
</Tabs>
281+
280282
Now, if you have a stack with the history `Home > Profile (userId: bob) > Settings` and you call `navigate(Profile, { userId: 'alice' })`, the resulting screens will be `Home > Profile (userId: bob) > Settings > Profile (userId: alice)` since it'll add a new `Profile` screen as no matching screen was found.
281283

284+
In a tab or drawer navigator, calling `navigate` will switch to the relevant screen if it's not focused already and update the params of the screen.
285+
282286
### `navigateDeprecated`
283287

284288
:::warning
@@ -287,7 +291,23 @@ This method is deprecated and will be removed in a future release. It only exist
287291

288292
:::
289293

290-
TODO
294+
The `navigateDeprecated` action implements the old behavior of `navigate` from previous versions.
295+
296+
It takes the following arguments:
297+
298+
`navigation.navigateDeprecated(name, params)`
299+
300+
- `name` - A destination name of the route that has been defined somewhere
301+
- `params` - Params to pass to the destination route.
302+
303+
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:
304+
305+
- If you're already on a screen with the same name, it will update its params and not push a new screen.
306+
- If a screen with the same name already exists in the stack, it will pop all the screens after it to go back to the existing screen.
307+
- If the [`getId`](screen.md#getid) prop is specified, and another screen in the stack has the same ID, it will pop any screens to navigate to that screen and update its params instead.
308+
- If none of the above conditions match, it'll push a new screen to the stack.
309+
310+
In a tab or drawer navigator, calling `navigate` will switch to the relevant screen if it's not focused already and update the params of the screen.
291311

292312
### `goBack`
293313

0 commit comments

Comments
 (0)