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
@@ -553,7 +551,7 @@ Preloading a screen means that the screen will be rendered in the background. Al
553
551
554
552
Depending on the navigator, `preload` may work differently:
555
553
556
-
- 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 forthe navigation to identify the preloaded screen. When`reuse` is `true`, a matching preloaded or existing route will be reused and its params will be updated.
554
+
- 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. Calling `preload` for a matching preloaded screen will update its params instead of adding a new preloaded screen. If [`getId`](screen.md#id) is specified, it'll be used formatching the preloaded screen. Otherwise, the screen name is used. If you need multiple preloaded instances of the same screen, use `getId` or [`reset`](#reset).
557
555
- 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.
@@ -917,7 +915,7 @@ Preloading a screen means that the screen will be rendered in the background. Al
917
915
918
916
Depending on the navigator, `preload` may work slightly differently:
919
917
920
-
- 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. When `reuse` is `true`, a matching preloaded or existing route will be reused and its params will be updated.
918
+
- 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. Calling `preload` for a matching preloaded screen will update its params instead of adding a new preloaded screen. If [`getId`](screen.md#id) is specified, it'll be used for matching the preloaded screen. Otherwise, the screen name is used. If you need multiple preloaded instances of the same screen, use `getId` or [`reset`](#reset).
921
919
- 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.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/upgrading-from-7.x.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -339,6 +339,20 @@ If you use a custom navigator with `StackRouter` and do not want to change the s
339
339
340
340
See [Navigation state](navigation-state.md) for more details.
341
341
342
+
##### `preload` reuses matching preloaded routes instead of adding new ones
343
+
344
+
Previously, calling `preload` for the same screen multiple times in a Stack or Native Stack Navigator would always preload a new instance of screen, leading to multiple preloaded instances. We found that this behavior was not intuitive and most people expected to have a single instance.
345
+
346
+
In React Navigation 8, calling `preload` for a matching preloaded screen updates its params instead of adding another preloaded screen:
347
+
348
+
```js
349
+
navigation.preload('Profile', { user:'jane' });
350
+
```
351
+
352
+
By default, preloaded screens are matched based on the screen name. The [`getId`](screen.md#id) prop can be used to match based on an ID derived from the params instead.
353
+
354
+
See [`preload`](navigation-actions.md#preload) for more details.
355
+
342
356
##### Preloaded screens behave closer to regular screens
343
357
344
358
Previously, when a screen was preloaded in Stack and Native Stack Navigators, there were a few restrictions:
@@ -852,18 +866,6 @@ This can be useful in various scenario:
852
866
853
867
See [`pushParams` docs](navigation-actions.md#pushparams) for more details.
854
868
855
-
### `preload` now supports a `reuse` option in Stack navigators
856
-
857
-
Previously, calling `preload` for the same screen multiple times in a Stack or Native Stack Navigator would add another preloaded route.
858
-
859
-
In React Navigation 8, you can pass `reuse: true` to update params for an existing preloaded or matching route instead:
See [`preload`](navigation-actions.md#preload) for more details.
866
-
867
869
### Themes now support `ColorValue` and CSS custom properties
868
870
869
871
Previously, theme colors only supported string values. In React Navigation 8, theme colors now support `PlatformColor`, `DynamicColorIOS` on native, and CSS custom properties on Web for more flexibility.
0 commit comments