Skip to content

Commit 00731a4

Browse files
author
hafidz
committed
translate fragments
1 parent fb98df2 commit 00731a4

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

content/docs/fragments.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ title: Fragments
44
permalink: docs/fragments.html
55
---
66

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.
7+
Pola umum dalam React adalah agar komponen mengembalikan banyak elemen. Fragmen memungkinkan anda mengelompokkan daftar komponen-komponen tanpa menambahkan node tambahan ke DOM.
8+
89

910
```js
1011
render() {
@@ -18,11 +19,12 @@ render() {
1819
}
1920
```
2021

21-
There is also a new [short syntax](#short-syntax) for declaring them.
22+
Ada juga [sintaks pendek](#short-syntax) untuk mendeklarasikannya.
23+
24+
## Motivasi {#motivation}
2225

23-
## Motivation {#motivation}
26+
Pola umum pada komponen adalah mengembalikan daftar komponen-komponen. Ambil potongan contoh react ini:
2427

25-
A common pattern is for a component to return a list of children. Take this example React snippet:
2628

2729
```jsx
2830
class Table extends React.Component {
@@ -38,7 +40,7 @@ class Table extends React.Component {
3840
}
3941
```
4042

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.
43+
`<Columns />` perlu mengembalikan beberapa `<td>` elemen agar HTML yang diberikan menjadi benar. Jika div induk digunakan di dalam `render()` dari `<Columns />`, maka HTML yang dihasilkan tidak benar.
4244

4345
```jsx
4446
class Columns extends React.Component {
@@ -53,7 +55,7 @@ class Columns extends React.Component {
5355
}
5456
```
5557

56-
results in a `<Table />` output of:
58+
menghasilkan keluaran `<Table />` dari:
5759

5860
```jsx
5961
<table>
@@ -66,9 +68,9 @@ results in a `<Table />` output of:
6668
</table>
6769
```
6870

69-
Fragments solve this problem.
71+
Fragmen memecahkan masalah ini
7072

71-
## Usage {#usage}
73+
## Penggunaan {#usage}
7274

7375
```jsx{4,7}
7476
class Columns extends React.Component {
@@ -83,7 +85,7 @@ class Columns extends React.Component {
8385
}
8486
```
8587

86-
which results in a correct `<Table />` output of:
88+
yang menghasilkan keluaran `<Table />` yang benar:
8789

8890
```jsx
8991
<table>
@@ -94,9 +96,9 @@ which results in a correct `<Table />` output of:
9496
</table>
9597
```
9698

97-
### Short Syntax {#short-syntax}
99+
### Sintaks Pendek {#short-syntax}
98100

99-
There is a new, shorter syntax you can use for declaring fragments. It looks like empty tags:
101+
Ada yang baru, sintaks yang lebih pendek dapat anda gunakan untuk mendeklarasikan fragmen. seperti tag kosong:
100102

101103
```jsx{4,7}
102104
class Columns extends React.Component {
@@ -111,18 +113,18 @@ class Columns extends React.Component {
111113
}
112114
```
113115

114-
You can use `<></>` the same way you'd use any other element except that it doesn't support keys or attributes.
116+
Anda dapat menggunakan `<></>` dengan cara yang sama anda akan menggunakan elemen lain kecuali itu tidak medukung *key* atau atribut.
115117

116118
### Keyed Fragments {#keyed-fragments}
117119

118-
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:
120+
Fragmen dideklarasikan dengan eksplisit `<React.Fragment>` sintaks mungkin memiliki *key*. Kasus penggunaan untuk ini adalah memetakan koleksi ke array fragmen -- untuk contoh, untuk membuat daftar deskripsi:
119121

120122
```jsx
121123
function Glossary(props) {
122124
return (
123125
<dl>
124126
{props.items.map(item => (
125-
// Without the `key`, React will fire a key warning
127+
// Tanpa sebuah `key`, React akan mengeluarkan peringatan
126128
<React.Fragment key={item.id}>
127129
<dt>{item.term}</dt>
128130
<dd>{item.description}</dd>
@@ -133,8 +135,9 @@ function Glossary(props) {
133135
}
134136
```
135137

136-
`key` is the only attribute that can be passed to `Fragment`. In the future, we may add support for additional attributes, such as event handlers.
138+
`key` adalah satu-satunya atribut yang dapat dteruskan ke `Fragment`. Dimasa mendatang, kami dapat menambahkan dukungan untuk atribut tambahan, seperti *event handlers*.
139+
140+
### Demo langsung {#live-demo}
137141

138-
### Live Demo {#live-demo}
142+
Anda dapat mencoba sintaks JSX fragmen baru dengan ini [CodePen](https://codepen.io/reactjs/pen/VrEbjE?editors=1000).
139143

140-
You can try out the new JSX fragment syntax with this [CodePen](https://codepen.io/reactjs/pen/VrEbjE?editors=1000).

0 commit comments

Comments
 (0)