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
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/components/img.md
+43-31Lines changed: 43 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,19 +125,18 @@ To create an explicit preload hint, call [`preload`](/reference/react-dom/preloa
125
125
126
126
### Waiting for an image during a View Transition {/*waiting-for-an-image-during-a-view-transition*/}
127
127
128
-
During a client-rendered [`<ViewTransition>`](/reference/react/ViewTransition) update, React may wait for an image to load and decode before starting the animation. This applies when a new `<img>` with a non-empty `src` is rendered, or when an existing image's `src` or `srcSet` changes. The image must be inside the `<ViewTransition>` subtree and must not have `loading="lazy"` or an `onLoad` handler. React does not wait for images during synchronous updates.
128
+
When a Suspense boundary reveals content inside a client-rendered [`<ViewTransition>`](/reference/react/ViewTransition), React may wait for a visible image to load and decode before starting the animation. This applies when a new `<img>` with a non-empty `src` is rendered, or when an existing image's `src` or `srcSet` changes. The image must be inside the `<ViewTransition>` subtree and must not have `loading="lazy"` or an `onLoad` handler. React stops waiting after a timeout so that a slow image does not block the update indefinitely.
129
129
130
-
When a Suspense boundary reveals streamed content inside a `<ViewTransition>`, React may also wait for visible images with a non-empty `src` that do not have `loading="lazy"`. React stops waiting after a timeout so that a slow image does not block the update indefinitely.
131
-
132
-
Because React does not wait for images during synchronous updates, this example wraps both state updates in [`startTransition`](/reference/react/startTransition). Compare what happens when React renders the image inside and outside a `<ViewTransition>`:
130
+
In this example, both versions suspend while reading the image source. Compare what happens to the `<img>` when the Suspense boundary reveals its content inside and outside a `<ViewTransition>`:
@@ -210,6 +211,17 @@ export function freshImageUrl() {
210
211
.cardp {
211
212
font-weight: bold;
212
213
}
214
+
.avatar-placeholder {
215
+
width: 80px;
216
+
height: 80px;
217
+
border-radius: 50%;
218
+
background: #dfe3e9;
219
+
}
220
+
.name-placeholder {
221
+
width: 90px;
222
+
border-radius: 4px;
223
+
background: #dfe3e9;
224
+
}
213
225
hr {
214
226
margin: 16px0;
215
227
}
@@ -227,4 +239,4 @@ hr {
227
239
228
240
</Sandpack>
229
241
230
-
Inside `<ViewTransition>`, React waits for the image before committing the card, up to a timeout. Outside it, React commits the card without waiting for the image.
242
+
Inside `<ViewTransition>`, React waits for the image before committing the Suspense reveal, up to a timeout. Outside it, React reveals the card without waiting for the image.
0 commit comments