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: content/docs/fragments.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
2
id: fragments
3
-
title: Fragments
3
+
title: フラグメント
4
4
permalink: docs/fragments.html
5
5
---
6
6
7
-
A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding extra nodes to the DOM.
@@ -38,7 +38,7 @@ class Table extends React.Component {
38
38
}
39
39
```
40
40
41
-
`<Columns />`would need to return multiple `<td>`elements in order for the rendered HTML to be valid. If a parent div was used inside the `render()`of `<Columns />`, then the resulting HTML will be invalid.
41
+
レンダーされる HTML が正しいものであるためには、`<Columns />`は複数の `<td>`要素を返す必要があります。 `<Columns />` 中の `render()`内で親の div 要素を使ってしまうと、結果として出力される HTML は不正なものとなってしまいます。
42
42
43
43
```jsx
44
44
classColumnsextendsReact.Component {
@@ -53,7 +53,7 @@ class Columns extends React.Component {
53
53
}
54
54
```
55
55
56
-
results in a `<Table />`output of:
56
+
上記では、以下のような `<Table />`の出力となってしまいます:
57
57
58
58
```jsx
59
59
<table>
@@ -66,9 +66,9 @@ results in a `<Table />` output of:
66
66
</table>
67
67
```
68
68
69
-
Fragments solve this problem.
69
+
フラグメントはこのような問題を解決します。
70
70
71
-
## Usage
71
+
## 使い方
72
72
73
73
```jsx{4,7}
74
74
class Columns extends React.Component {
@@ -83,7 +83,7 @@ class Columns extends React.Component {
83
83
}
84
84
```
85
85
86
-
which results in a correct `<Table />`output of:
86
+
上記は、以下のような正しい `<Table />`の出力となります:
87
87
88
88
```jsx
89
89
<table>
@@ -94,9 +94,9 @@ which results in a correct `<Table />` output of:
94
94
</table>
95
95
```
96
96
97
-
### Short Syntax
97
+
### 短い記法
98
98
99
-
There is a new, shorter syntax you can use for declaring fragments. It looks like empty tags:
99
+
フラグメントを宣言するための新しい短縮記法があります。それは空のタグのようにも見えます:
100
100
101
101
```jsx{4,7}
102
102
class Columns extends React.Component {
@@ -111,13 +111,13 @@ class Columns extends React.Component {
111
111
}
112
112
```
113
113
114
-
You can use `<></>`the same way you'd use any other element except that it doesn't support keys or attributes.
Note that **[many tools don't support it yet](/blog/2017/11/28/react-v16.2.0-fragment-support.html#support-for-fragment-syntax)** so you might want to explicitly write `<React.Fragment>`until the tooling catches up.
Fragments declared with the explicit `<React.Fragment>`syntax may have keys. A use case for this is mapping a collection to an array of fragments -- for example, to create a description list:
0 commit comments