You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -66,11 +91,32 @@ If we call `navigation.navigate` with a route name that we haven't defined in a
66
91
67
92
So we now have a stack with two routes: 1) the `Home` route 2) the `Details` route. What would happen if we navigated to the `Details` route again, from the `Details` screen?
68
93
69
-
## Navigate to a route multiple times
94
+
## Navigate to a screen multiple times
95
+
96
+
```js name="Navigate to a screen multiple times" snack version=7
If you run this code, you'll notice that when you tap "Go to Details... again" that it doesn't do anything! This is because we are already on the Details route. The `navigate` function roughly means "go to this screen", and if you are already on that screen then it makes sense that it would do nothing.
150
+
If you run this code, you'll notice that when you tap "Go to Details... again", it doesn't do anything! This is because we are already on the Details route. The `navigate` function roughly means "go to this screen", and if you are already on that screen then it makes sense that it would do nothing.
90
151
91
152
Let's suppose that we actually _want_ to add another details screen. This is pretty common in cases where you pass in some unique data to each route (more on that later when we talk about `params`!). To do this, we can change `navigate` to `push`. This allows us to express the intent to add another route regardless of the existing navigation history.
92
153
93
-
<sampid="multiple-push" />
154
+
```js name="Navigate to a screen multiple times" snack version=7
@@ -111,11 +217,32 @@ Each time you call `push` we add a new route to the navigation stack. When you c
111
217
112
218
The header provided by the native stack navigator will automatically include a back button when it is possible to go back from the active screen (if there is only one screen in the navigation stack, there is nothing that you can go back to, and so there is no back button).
113
219
114
-
Sometimes you'll want to be able to programmatically trigger this behavior, and for that you can use `navigation.goBack();`.
220
+
Sometimes you'll want to be able to programmatically trigger this behavior, and for that, you can use `navigation.goBack()`.
@@ -141,9 +284,30 @@ On Android, React Navigation hooks in to the hardware back button and fires the
141
284
142
285
Another common requirement is to be able to go back _multiple_ screens -- for example, if you are several screens deep in a stack and want to dismiss all of them to go back to the first screen. In this case, we know that we want to go back to `Home` so we can use `popTo('Home')`. Another alternative would be `navigation.popToTop()`, which goes back to the first screen in the stack.
143
286
144
-
<sampid="pop-to-top" />
287
+
```js name="Going back to specific screen" snack version=7
0 commit comments