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
@@ -2375,17 +2375,15 @@ The server HTML will include the loading indicator. It will be replaced by the `
2375
2375
2376
2376
### Waiting for a stylesheet to load {/*waiting-for-a-stylesheet-to-load*/}
2377
2377
2378
-
A stylesheet rendered with [`<link rel="stylesheet">` and a `precedence` prop](/reference/react-dom/components/link#special-rendering-behavior) blocks the boundary until the stylesheet loads, up to a timeout, so the content doesn't appear unstyled.
2378
+
A stylesheet rendered with [`<link rel="stylesheet">` and a `precedence` prop](/reference/react-dom/components/link#special-rendering-behavior) blocks the Suspense boundary until the stylesheet loads, up to a timeout, so the content doesn't appear unstyled.
2379
2379
2380
2380
In the example below, the `Card` component renders a stylesheet with `precedence`. Press "Show card": React shows the fallback until the stylesheet has loaded, and then reveals the card with its styles applied:
@@ -2682,18 +2690,19 @@ Where you place the `<ViewTransition>` relative to the boundary determines wheth
2682
2690
2683
2691
### Waiting for a font to load {/*waiting-for-a-font-to-load*/}
2684
2692
2685
-
<CanaryBadge /> When a [`<ViewTransition>`](/reference/react/ViewTransition) animates a boundary's reveal, React also waits for new fonts the content introduces, up to a timeout, so the text doesn't flash with a fallback font. This only happens during a `<ViewTransition>` update.
2693
+
<CanaryBadge /> When a [`<ViewTransition>`](/reference/react/ViewTransition) animates a Suspense boundary's reveal, React also waits for new fonts the content introduces, up to a timeout, so the text doesn't flash with a fallback font. This only happens during a `<ViewTransition>` update.
2694
+
2695
+
In the example below, the Suspense boundary is wrapped in a `<ViewTransition>`, and the `Quote` component suspends while its data loads. Rendering the quote starts its font download. React keeps the fallback visible until the font has loaded, so the quote appears already in its font.
2686
2696
2687
-
In the example below, the `Quote` component suspends while its data loads. Rendering the quote starts its font download, so React keeps the fallback visible until the font has loaded, and the quote appears already in its font:
2697
+
For comparison, the second button performs the same update with plain DOM, without React. Nothing waits for the font, so the text appears in a fallback font first and then switches:
// Note: the way you would do data fetching depends on
2741
2788
// the framework that you use together with Suspense.
@@ -2751,7 +2798,7 @@ export function fetchQuote() {
2751
2798
resolve(
2752
2799
'The best way to predict the future is to invent it.'
2753
2800
);
2754
-
}, 1500);
2801
+
}, 500);
2755
2802
});
2756
2803
}
2757
2804
return cache;
@@ -2760,14 +2807,20 @@ export function fetchQuote() {
2760
2807
2761
2808
```css
2762
2809
#root {
2763
-
min-height:100px;
2810
+
min-height:260px;
2764
2811
}
2765
2812
.quote {
2766
2813
font-size:20px;
2767
2814
margin-top:1em;
2768
2815
}
2769
2816
.fancy {
2770
-
font-family:'Fancy', cursive;
2817
+
font-family:'Fancy', sans-serif;
2818
+
}
2819
+
.vanilla-fancy {
2820
+
font-family:'VanillaFancy', sans-serif;
2821
+
}
2822
+
hr {
2823
+
margin:16px0;
2771
2824
}
2772
2825
```
2773
2826
@@ -2787,22 +2840,24 @@ export function fetchQuote() {
2787
2840
2788
2841
### Waiting for an image to load {/*waiting-for-an-image-to-load*/}
2789
2842
2790
-
<CanaryBadge /> Images work the same way: when a [`<ViewTransition>`](/reference/react/ViewTransition) animates a boundary's reveal, React waits for visible images to load, up to a timeout, so the animation doesn't start with a half-loaded image. This only happens during a `<ViewTransition>` update. Adding an `onLoad` handler opts a specific image out, even inside a `<ViewTransition>`.
2843
+
<CanaryBadge /> Images work the same way: when a [`<ViewTransition>`](/reference/react/ViewTransition) animates a Suspense boundary's reveal, React waits for visible images to load, up to a timeout, so the animation doesn't start with a half-loaded image. This only happens during a `<ViewTransition>` update. Adding an `onLoad` handler opts a specific image out, even inside a `<ViewTransition>`.
2844
+
2845
+
In the example below, the Suspense boundary is wrapped in a `<ViewTransition>` and shows its fallback until the portrait has loaded.
2791
2846
2792
-
In the example below, the boundary shows its fallback until the portrait has loaded:
2847
+
For comparison, the second button performs the same update with plain DOM, without React. Nothing waits for the image, so the card appears immediately and the image pops in when it loads:
Copy file name to clipboardExpand all lines: src/content/reference/react/ViewTransition.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
@@ -1264,7 +1264,7 @@ It's important to properly use keys to preserve identity when reordering lists.
1264
1264
1265
1265
### Animating from Suspense content {/*animating-from-suspense-content*/}
1266
1266
1267
-
Like any Transition, React waits for data and new CSS (`<link rel="stylesheet" precedence="...">`) before running the animation. In addition to this, ViewTransitions also wait up to 500ms for new fonts to load before starting the animation to avoid them flickering in later. For the same reason, an image wrapped in ViewTransition will wait for the image to load.
1267
+
Like any Transition, React waits for data and new CSS (`<link rel="stylesheet" precedence="...">`) before running the animation. In addition to this, ViewTransitions also wait up to 500ms for new fonts to load before starting the animation to avoid them flickering in later. For the same reason, an image wrapped in ViewTransition will wait for the image to load. See examples of [waiting for a font](/reference/react/Suspense#waiting-for-a-font-to-load) and [waiting for an image](/reference/react/Suspense#waiting-for-an-image-to-load) on the Suspense page.
1268
1268
1269
1269
If it's inside a new Suspense boundary instance, then the fallback is shown first. After the Suspense boundary fully loads, it triggers the `<ViewTransition>` to animate the reveal to the content.
0 commit comments