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
### Returning multiple elements {/*returning-multiple-elements*/}
41
+
### 複数の要素を返す {/*returning-multiple-elements*/}
42
42
43
-
Use`Fragment`, or the equivalent `<>...</>`syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group:
Fragments are useful because grouping elements with a Fragment has no effect on layout or styles, unlike if you wrapped the elements in another container like a DOM element. If you inspect this example with the browser tools, you'll see that all `<h1>`and`<article>` DOM nodes appear as siblings without wrappers around them:
56
+
`Fragment` は有用です。なぜなら、要素を `Fragment` でまとめることは、DOM 要素のような他のコンテナで要素をラップする場合と異なり、レイアウトやスタイルに影響を与えないからです。この例をブラウザツールで検証すると、全ての `<h1>`や`<article>` DOM ノードがそれらを囲むラッパーなしに兄弟として表示されることがわかります。
57
57
58
58
<Sandpack>
59
59
@@ -93,9 +93,9 @@ function PostBody({ body }) {
93
93
94
94
<DeepDive>
95
95
96
-
#### How to write a Fragment without the special syntax? {/*how-to-write-a-fragment-without-the-special-syntax*/}
@@ -157,9 +156,9 @@ function DateRangePicker({ start, end }) {
157
156
158
157
---
159
158
160
-
### Rendering a list of Fragments {/*rendering-a-list-of-fragments*/}
159
+
### Fragment のリストをレンダーする {/*rendering-a-list-of-fragments*/}
161
160
162
-
Here's a situation where you need to write `Fragment` explicitly instead of using the `<></>`syntax. When you [render multiple elements in a loop](/learn/rendering-lists), you need to assign a `key`to each element. If the elements within the loop are Fragments, you need to use the normal JSX element syntax in order to provide the `key` attribute:
161
+
以下は `<></>`構文の代わりに `Fragment` を明示的に記述する必要がある場面です。ループ内で[複数の要素をレンダーする]((/learn/rendering-lists))ときには、各要素に key を割り当てる必要があります。ループ内の要素が Fragment である場合は、`key`属性を提供するために標準的な JSX 要素の構文を使用する必要があります。
163
162
164
163
```js {3,6}
165
164
functionBlog() {
@@ -172,7 +171,7 @@ function Blog() {
172
171
}
173
172
```
174
173
175
-
You can inspect the DOM to verify that there are no wrapper elements around the Fragment children:
0 commit comments