In the previous section Hello React Navigation we defined a stack navigator with two routes
Details, but we didn’t know how to let the user go from
If it was a web browser, we could write something like this:
We'll do something like this, but instead of using the global window window.location we will use the
navigation property that is passed to our screen components.
Let's deal with this:
navigationproperty is passed to each screen component in the stack navigator.
navigate ('Details')- we call the
navigatefunction with the name of the route we would like to navigate the user.
If we call
navigation.navigate with a route name that we did not define in the navigator, it will throw an error in development assemblies and nothing will happen in production assemblies. In other words, we can only jump to routes that have been defined in our navigator - we cannot jump to an arbitrary component.
Thanks goes to these wonderful people (emoji key):