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
{{ message }}
Repository navigation
Commit 44bd0c3
Browse filesBrowse the repository at this point in the historyBrowse files
*`alt`: a string. Specifies alternative text for the image. Use an empty string for a purely decorative image.
36
-
*`crossOrigin`: a string. Specifies the [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use when fetching the image. The possible values are `anonymous`and`use-credentials`.
37
-
*`decoding`: a string. Suggests whether the browser should wait to decode the image before presenting other content. The possible values are `async`, `sync`, and `auto` (the default).
38
-
*`fetchPriority`: a string. Suggests a relative priority for fetching the image. The possible values are `high`, `low`, and `auto` (the default). During server rendering, `fetchPriority="low"`also prevents React from [automatically preloading the image.](#controlling-image-preloading-during-server-rendering)
39
-
*`height`: a number or string. Specifies the rendered height of the image.
40
-
*`loading`: a string. Specifies whether the browser should defer loading the image until it is near the viewport. The possible values are `eager` (the default) and `lazy`. Setting `loading="lazy"`prevents React from [automatically preloading the image.](#controlling-image-preloading-during-server-rendering)
41
-
*`onError`: an [event handler](/reference/react-dom/components/common#event-handler) function. Fires when the image fails to load.
42
-
*`onLoad`: an [event handler](/reference/react-dom/components/common#event-handler) function. Fires when the image finishes loading. Passing `onLoad`prevents React from [waiting for the image during a client-rendered View Transition update.](#waiting-for-an-image-during-a-view-transition)
43
-
*`referrerPolicy`: a string. Specifies the [referrer information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy) to send when fetching the image.
44
-
*`sizes`: a string. Specifies the image sizes for different page layouts. Used with `srcSet`.
45
-
*`src`: a string. Specifies the URL of the image.
46
-
*`srcSet`: a string. Specifies one or more candidate image sources for the browser to choose from.
47
-
*`useMap`: a string. Associates the image with a [client-side image map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map).
48
-
*`width`: a number or string. Specifies the rendered width of the image.
*Do not pass an empty string to `src`. It may cause the browser to request the current page again. React warns in development and omits the attribute. To render no image, omit the `<img>`or pass `null` to `src`.
53
-
*`<img>`cannot have children or use `dangerouslySetInnerHTML`. React throws an error if you pass either.
54
-
*`fetchPriority="low"`does not stop React from waiting for the image to load and decode during a client-rendered View Transition update. Use `loading="lazy"`or an `onLoad`handler to opt out of that behavior.
Pass the image URL to `src`and a text description to `alt`:
62
+
`src`に画像の URL を、`alt` にテキストによる説明を渡します。
63
63
64
64
<Sandpack>
65
65
@@ -85,15 +85,15 @@ img {
85
85
86
86
</Sandpack>
87
87
88
-
Specify`width`and`height`when you know the image dimensions so the browser can reserve space before the image loads. For a decorative image, pass `alt=""`so that screen readers ignore it.
During server rendering, React automatically generates a preload hint for an `<img>`by default. This can let the browser start fetching the image before it encounters the `<img>`in the rendered HTML.
94
+
サーバレンダリング中、React はデフォルトで `<img>`に対するプリロードヒントを自動的に生成します。これにより、ブラウザはレンダーされた HTML 内で `<img>`に出会う前に、画像のフェッチを開始できるようになります。
95
95
96
-
Add `loading="lazy"`or`fetchPriority="low"`to an image that should not receive this hint:
In this example, React generates a preload hint only for `hero.jpg`. Depending on the server API or framework, React may render the equivalent of this element:
110
+
この例では、React は `hero.jpg` に対してのみプリロードヒントを生成します。使用するサーバ API やフレームワークによっては、React は以下のような要素に相当するものをレンダーすることがあります。
111
111
112
112
```html
113
113
<linkrel="preload"as="image"href="hero.jpg" />
114
114
```
115
115
116
-
React may instead provide the same hint in a `Link`response header. The other two images keep their `loading`and`fetchPriority` props in the rendered HTML, but React does not generate preload hints for them. The `loading="lazy"`prop asks the browser to defer loading an image until it approaches the viewport. The `fetchPriority="low"`prop allows the image to load immediately, but tells the browser to fetch it at a lower priority.
116
+
代わりに、同じヒントを `Link`レスポンスヘッダで提供する場合もあります。残りの 2 つの画像については、レンダーされた HTML に `loading`や`fetchPriority`の props がそのまま残りますが、React はプリロードヒントを生成しません。`loading="lazy"`は、画像がビューポートに近づくまで読み込みを遅延させるようブラウザに求めます。`fetchPriority="low"`は画像をすぐに読み込むことを許可しますが、低い優先度でフェッチするようブラウザに伝えます。
117
117
118
-
React also does not automatically preload an image when it is inside a `<picture>`or`<noscript>`element, or when its `src`or`srcSet`is a data URL.
118
+
また、画像が `<picture>`要素や`<noscript>`要素の内部にある場合や、`src`または`srcSet`が data URL である場合も、React は画像を自動的にプリロードしません。
119
119
120
-
If you render an image through a framework or a component library, consult its documentation for the default behavior. React decides whether to generate an automatic preload from the props of the underlying `<img>`. For example, an image component may add `loading="lazy"`by default and provide a separate option for explicitly preloading selected images.
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.
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
-
In this example, the Suspense boundary is wrapped in a `<ViewTransition>` and shows a profile skeleton until the portrait has loaded.
133
-
134
-
For comparison, the second button inserts the same card directly into the DOM. The card appears immediately, and the browser displays the image after it loads:
0 commit comments