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
constroutes= [...activeRoutes.slice(0, index +1), ...extraRoutes];
228
231
229
232
returnCommonActions.reset({
230
233
...state,
231
234
routes,
232
-
index:routes.length-1,
235
+
index,
233
236
});
234
237
});
235
238
```
@@ -522,8 +525,6 @@ Depending on the navigator, `preload` may work differently:
522
525
- In a stack navigator ([stack](stack-navigator.md), [native stack](native-stack-navigator.md)), the screen will be rendered off-screen and animated in when you navigate to it. If [`getId`](screen.md#id) is specified, it'll be used for the navigation to identify the preloaded screen.
523
526
- In a tab or drawer navigator ([bottom tabs](bottom-tab-navigator.md), [material top tabs](material-top-tab-navigator.md), [drawer](drawer-navigator.md), etc.), the existing screen will be rendered as if`lazy` was set to `false`. Calling`preload` on a screen that is already rendered will not have any effect.
524
527
525
-
When a screen is preloaded in a stack navigator, it can't dispatch navigation actions (e.g. `navigate`, `goBack`, etc.) until it becomes active.
526
-
527
528
### setParams
528
529
529
530
The `setParams` action allows to merge params for a certain route. It takes the following arguments:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/navigation-object.md
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -914,8 +914,6 @@ Depending on the navigator, `preload` may work slightly differently:
914
914
- In a stack navigator ([stack](stack-navigator.md), [native stack](native-stack-navigator.md)), the screen will be rendered off-screen and animated in when you navigate to it. If [`getId`](screen.md#id) is specified, it'll be used for the navigation to identify the preloaded screen.
915
915
- In a tab or drawer navigator ([bottom tabs](bottom-tab-navigator.md), [material top tabs](material-top-tab-navigator.md), [drawer](drawer-navigator.md), etc.), the existing screen will be rendered as if `lazy` was set to `false`. Calling `preload` on a screen that is already rendered will not have any effect.
916
916
917
-
When a screen is preloaded in a stack navigator, it can't dispatch navigation actions (e.g. `navigate`, `goBack`, etc.) until it becomes active.
918
-
919
917
### `setParams`
920
918
921
919
The `setParams` method lets us update the params (`route.params`) of the current screen. `setParams` works like React's `setState` - it shallow merges the provided params object with the current params.
You can use this functionality to build your own helpers that you can utilize in your app. Here is an example which implements inserting a screen just before the last one:
1704
+
You can use this functionality to build your own helpers that you can utilize in your app. Here is an example which implements inserting a screen just before the focused one:
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/navigation-state.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ There are few properties present in every navigation state object:
27
27
-`type` - Type of the navigator that the state belongs to, e.g. `stack`, `tab`, `drawer`.
28
28
-`key` - Unique key to identify the navigator.
29
29
-`routeNames` - Name of the screens defined in the navigator. This is an unique array containing strings for each screen.
30
-
-`routes` - List of route objects (screens) which are rendered in the navigator. It also represents the history in a stack navigator. There should be at least one item present in this array.
30
+
-`routes` - List of route objects (screens) which are rendered in the navigator. In a stack or native stack navigator, the entries up to and including `index` also represent the history. There should be at least one item present in this array.
31
31
-`index` - Index of the focused route object in the `routes` array.
32
32
-`history` - An optional list of visited items. See [History stack](#history-stack) for more details.
33
33
-`stale` - A navigation state is assumed to be stale unless the `stale` property is explicitly set to `false`. This means that the state object needs to be ["rehydrated"](#stale-state-objects).
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/upgrading-from-7.x.md
+33-1Lines changed: 33 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -301,7 +301,39 @@ createBottomTabNavigator({
301
301
</TabItem>
302
302
</Tabs>
303
303
304
-
#### Preloaded screens now behave differently
304
+
#### Preloaded routes in Stack have been reworked
305
+
306
+
Preloaded routes in Stack and Native Stack Navigators have been reworked to remove various restrictions.
307
+
308
+
The rework has 2 main consequences:
309
+
310
+
##### Stack navigation state shape has changed
311
+
312
+
Previously, the navigation state for Stack and Native Stack Navigators was as follows:
313
+
314
+
-`state.routes` - array of route objects for active screens in the stack, limited by `state.index`.
315
+
-`state.preloadedRoutes` - array of route objects for preloaded screens in the stack.
316
+
317
+
After, the rework:
318
+
319
+
-`state.routes` - array of route objects for all screens, including preloaded screens, which can extend beyond `state.index` and the routes after `state.index` are considered preloaded.
320
+
-`state.preloadedRoutes` - no longer exists.
321
+
322
+
So if your code had assumptions about `state.routes` being limited by `state.index` (e.g. determining focused route by checking if it's the last route in `state.routes` instead of using `state.index`), you may need to update it to check for `state.index` instead.
0 commit comments