Skip to content

Commit

Permalink
Document navigateDeprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 9, 2024
1 parent 3cd824e commit 107c0c1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions versioned_docs/version-7.x/navigation-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ In a stack navigator ([stack](stack-navigator.md) or [native stack](native-stack

- If you're already on a screen with the same name, it will update its params and not push a new screen.
- If you're on a different screen, it will push the new screen onto the stack.
- 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.
- 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.
- If none of the above conditions match, it'll push a new screen to the stack.

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.

Expand Down Expand Up @@ -277,8 +278,11 @@ const Tabs = createBottomTabNavigator({

</TabItem>
</Tabs>

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.

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.

### `navigateDeprecated`

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

:::

TODO
The `navigateDeprecated` action implements the old behavior of `navigate` from previous versions.

It takes the following arguments:

`navigation.navigateDeprecated(name, params)`

- `name` - A destination name of the route that has been defined somewhere
- `params` - Params to pass to the destination route.

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:

- If you're already on a screen with the same name, it will update its params and not push a new screen.
- 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.
- 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.
- If none of the above conditions match, it'll push a new screen to the stack.

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.

### `goBack`

Expand Down

0 comments on commit 107c0c1

Please sign in to comment.