Skip to content

Commit d611638

Browse files
committed
first pass at key docs
1 parent e2fe842 commit d611638

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

docs/navigation-key.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
id: navigation-key
3+
title: Using the navigation key
4+
sidebar_label: Using the navigation key
5+
---
6+
7+
The `key` parameter comes up repeatedly across different navigation functions. Let's take a look at a summary of its use cases:
8+
9+
### Idempotent navigation with the [`navigate` call](/docs/navigation-actions.html#navigate)
10+
11+
`navigate` function accepts an optional `key` parameter which is used as an identifier for the route to navigate to. If you provide the identifier (as for example in `navigate({ routeName: 'someScreen', params: { someParam: 'someValue' }, key: 'someScreen' })`) and user triggers such navigation action multiple times (eg. by pushing a button that calls the navigation action quickly multiple times in a row), the navigation action will be executed only once.
12+
13+
Without using the key, calling `navigate({ routeName: 'someScreen' })` twice would result in pushing the screen onto the stack two times. Providing the `key` instead results into one push only. The second call to `navigate` finds out that the screen is already present on the stack and instead of pushing a new instance of the same screen, it calls `setParams` on the existing screen. // TODO what if a screen with given key is present "earlier" in the navigation stack? Will it go back?
14+
15+
### Usage with [`reset`](/docs/navigation-actions.html#reset)
16+
17+
When resetting, `key` is also optional and can be a string or null. If set, the navigator with the given key will reset. If null, the root navigator will reset.
18+
// TODO how to find navigator key?
19+
20+
### Usage with [`replace`](/docs/navigation-actions.html#replace)
21+
22+
With replace, key is a required parameter used for identifying the route to be replaced.
23+
24+
### Usage with `goBack`
25+
26+
Please refer to the [`goBack docs`](/docs/navigation-prop.html#goback-close-the-active-screen-and-move-back) for a detailed explanation.

website/i18n/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"Hello React Navigation": "Hello React Navigation",
5656
"help": "Get help",
5757
"Get help": "Get help",
58+
"limitations": "Limitations",
59+
"Limitations": "Limitations",
5860
"listen-lifecycle-events": "Know when a screen is focused and blurred",
5961
"Know when a screen is focused and blurred": "Know when a screen is focused and blurred",
6062
"material-bottom-tab-navigator": "createMaterialBottomTabNavigator",
@@ -69,6 +71,8 @@
6971
"Moving between screens": "Moving between screens",
7072
"navigation-actions": "NavigationActions reference",
7173
"NavigationActions": "NavigationActions",
74+
"navigation-key": "Using the navigation key",
75+
"Using the navigation key": "Using the navigation key",
7276
"navigation-options": "navigation-options",
7377
"Configuring Navigation Options": "Configuring Navigation Options",
7478
"navigation-prop": "Navigation prop reference",

website/sidebars.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"navigating-without-navigation-prop",
2525
"deep-linking",
2626
"screen-tracking",
27-
"redux-integration"
27+
"redux-integration",
28+
"navigation-key"
2829
],
2930
"Build your own Navigator": [
3031
"custom-navigator-overview",

0 commit comments

Comments
 (0)