Skip to content

Conversation

vonovak
Copy link
Member

@vonovak vonovak commented Apr 2, 2018

closes #50

### Idempotent navigation with the [`navigate` call](/docs/navigation-actions.html#navigate)

`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.

This comment was marked as abuse.


### Usage with [`reset`](/docs/navigation-actions.html#reset)

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.

This comment was marked as abuse.


### Usage with [`replace`](/docs/navigation-actions.html#replace)

With replace, key is a required parameter used for identifying the route to be replaced.

This comment was marked as abuse.


### Usage with `goBack`

Please refer to the [`goBack docs`](/docs/navigation-prop.html#goback-close-the-active-screen-and-move-back) for a detailed explanation.

This comment was marked as abuse.

@vonovak vonovak changed the title [wip] key docs Key docs Apr 16, 2018

### Usage with the [`navigate`](/docs/navigation-actions.html#navigate) call

TL;DR: The behavior of `navigate` together with `key` depends on the version of react-navigation you use. In v1, key has to be provided for navigate to behave idempotently. In v2, this is no longer needed.

This comment was marked as abuse.

@vonovak vonovak force-pushed the @vonovak/key-docs branch from f56dd53 to c010f5a Compare April 29, 2018 19:28
@brentvatne
Copy link
Member

thank you! this will be very helpful for people

@brentvatne brentvatne merged commit 254a7b6 into source Apr 30, 2018
@vonovak vonovak deleted the @vonovak/key-docs branch April 30, 2018 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explain the navigation route key

2 participants