Skip to content

Commit 5773fb8

Browse files
committed
wip
1 parent 1db3fa8 commit 5773fb8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Diff for: src/content/reference/react/Fragment.md

+12-13
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ title: <Fragment> (<>...</>)
3636
- React は、`<><Child /></>` のレンダーから `[<Child />]` への変更、あるいはその逆、または `<><Child /></>` のレンダーから `<Child />` への変更、その逆に移行するときに [state をリセット](/learn/preserving-and-resetting-state) しません。これは 1 つのレベルまでのみ機能します:例えば、`<><><Child /></></>` から `<Child />` への変更は state をリセットします。詳細については [こちら](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b) をご覧ください。
3737
---
3838

39-
## Usage {/*usage*/}
39+
## 使い方 {/*usage*/}
4040

41-
### Returning multiple elements {/*returning-multiple-elements*/}
41+
### 複数の要素を返す {/*returning-multiple-elements*/}
4242

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:
43+
複数の要素をまとめるために `Fragment` や同等の `<>...</>` 構文を使用します。単一の要素が行くことができる任意の場所に複数の要素を置くことができます。例えば、コンポーネントは 1 つの要素しか返すことができませんが、`Fragment` を使用することで複数の要素をまとめてグループとして返すことができます。
4444

4545
```js {3,6}
4646
function Post() {
@@ -53,7 +53,7 @@ function Post() {
5353
}
5454
```
5555

56-
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 ノードがそれらを囲むラッパーなしに兄弟として表示されることがわかります。
5757

5858
<Sandpack>
5959

@@ -93,9 +93,9 @@ function PostBody({ body }) {
9393

9494
<DeepDive>
9595

96-
#### How to write a Fragment without the special syntax? {/*how-to-write-a-fragment-without-the-special-syntax*/}
96+
#### 特別な構文を使わずにFragmentをどのように記述するか? {/*how-to-write-a-fragment-without-the-special-syntax*/}
9797

98-
The example above is equivalent to importing `Fragment` from React:
98+
上述の例は、React から `Fragment` をインポートすることと同じです:
9999

100100
```js {1,5,8}
101101
import { Fragment } from 'react';
@@ -110,15 +110,14 @@ function Post() {
110110
}
111111
```
112112

113-
Usually you won't need this unless you need to [pass a `key` to your `Fragment`.](#rendering-a-list-of-fragments)
114-
113+
通常なら [Fragment に key を渡す](#rendering-a-list-of-fragments) 必要がある場合以外では必要ありません。
115114
</DeepDive>
116115

117116
---
118117

119-
### Assigning multiple elements to a variable {/*assigning-multiple-elements-to-a-variable*/}
118+
### 複数の要素を変数に割り当てる {/*assigning-multiple-elements-to-a-variable*/}
120119

121-
Like any other element, you can assign Fragment elements to variables, pass them as props, and so on:
120+
他の要素と同じように、Fragment の要素を変数に割り当てたり、props として渡したりすることができます:
122121

123122
```js
124123
function CloseDialog() {
@@ -157,9 +156,9 @@ function DateRangePicker({ start, end }) {
157156
158157
---
159158
160-
### Rendering a list of Fragments {/*rendering-a-list-of-fragments*/}
159+
### Fragment のリストをレンダーする {/*rendering-a-list-of-fragments*/}
161160
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 要素の構文を使用する必要があります。
163162
164163
```js {3,6}
165164
function Blog() {
@@ -172,7 +171,7 @@ function Blog() {
172171
}
173172
```
174173
175-
You can inspect the DOM to verify that there are no wrapper elements around the Fragment children:
174+
Fragment の子要素の周りにラッパー要素がないことを確認するために、DOM を検査できます:
176175
177176
<Sandpack>
178177

0 commit comments

Comments
 (0)