Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
key behavior in react-navigation v1.x.x

v1 behavior

In v1, key parameter 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 twice (eg. by pushing a button that calls the navigation action quickly twice in a row), the navigation action will be executed only once. The second call to navigate finds out that the route with the key is already present on the stack and instead of pushing a new instance of the same route, it calls setParams on the existing one.

Without using the key, calling navigate({ routeName: 'someScreen' }) twice would result in pushing the route onto the stack two times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.