Skip to content

Commit ee948a8

Browse files
committed
docs: translating recap & challenges section
1 parent 8c5d38a commit ee948a8

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/content/learn/updating-arrays-in-state.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -777,21 +777,21 @@ Di belakang layar, Immer selalu membuat state berikutnya dari awal sesuai dengan
777777

778778
<Recap>
779779

780-
- You can put arrays into state, but you can't change them.
781-
- Instead of mutating an array, create a *new* version of it, and update the state to it.
782-
- You can use the `[...arr, newItem]` array spread syntax to create arrays with new items.
783-
- You can use `filter()` and `map()` to create new arrays with filtered or transformed items.
784-
- You can use Immer to keep your code concise.
780+
- Anda dapat memasukkan senarai ke dalam state, tetapi Anda tidak dapat mengubahnya.
781+
- Alih-alih memutasi senarai, buat versi *barunya*, dan perbarui state tersebut.
782+
- Anda dapat menggunakan penyebaran sintaksis senarai `[...arr, newItem]` untuk membuat senarai dengan item baru.
783+
- Anda dapat menggunakan `filter()` dan `map()` untuk membuat senarai baru dengan item yang difilter atau diubah.
784+
- Anda dapat menggunakan Immer untuk menjaga agar kode Anda tetap ringkas.
785785

786786
</Recap>
787787

788788

789789

790790
<Challenges>
791791

792-
#### Update an item in the shopping cart {/*update-an-item-in-the-shopping-cart*/}
792+
#### Memperbarui item di keranjang belanja {/*update-an-item-in-the-shopping-cart*/}
793793

794-
Fill in the `handleIncreaseClick` logic so that pressing "+" increases the corresponding number:
794+
Isi logika `handleIncreaseClick` sehingga saat menekan "+" akan meningkatkan angka yang sesuai:
795795

796796
<Sandpack>
797797

@@ -849,7 +849,7 @@ button { margin: 5px; }
849849

850850
<Solution>
851851

852-
You can use the `map` function to create a new array, and then use the `...` object spread syntax to create a copy of the changed object for the new array:
852+
Anda dapat menggunakan fungsi `map` untuk membuat senarai baru, lalu menggunakan penyebaran sintaksis objek `...` untuk membuat salinan objek yang diubah untuk senarai baru:
853853

854854
<Sandpack>
855855

@@ -916,9 +916,9 @@ button { margin: 5px; }
916916

917917
</Solution>
918918

919-
#### Remove an item from the shopping cart {/*remove-an-item-from-the-shopping-cart*/}
919+
#### Menghapus item dari keranjang belanja {/*remove-an-item-from-the-shopping-cart*/}
920920

921-
This shopping cart has a working "+" button, but the "–" button doesn't do anything. You need to add an event handler to it so that pressing it decreases the `count` of the corresponding product. If you press "–" when the count is 1, the product should automatically get removed from the cart. Make sure it never shows 0.
921+
Keranjang belanja ini memiliki tombol "+" yang berfungsi, tetapi tombol "–" tidak melakukan apa-apa. Anda perlu menambahkan *event handler* ke dalamnya sehingga saat menekannya akan mengurangi `count` produk yang sesuai. Jika Anda menekan "–" saat `count` 1, produk akan secara otomatis dihapus dari keranjang. Pastikan itu tidak pernah menunjukkan 0.
922922

923923
<Sandpack>
924924

@@ -988,7 +988,7 @@ button { margin: 5px; }
988988

989989
<Solution>
990990

991-
You can first use `map` to produce a new array, and then `filter` to remove products with a `count` set to `0`:
991+
Pertama-tama Anda dapat menggunakan `map` untuk menghasilkan senarai baru, lalu `filter` untuk menghapus produk dengan `count` yang disetel ke 0:
992992

993993
<Sandpack>
994994

@@ -1077,9 +1077,9 @@ button { margin: 5px; }
10771077

10781078
</Solution>
10791079

1080-
#### Fix the mutations using non-mutative methods {/*fix-the-mutations-using-non-mutative-methods*/}
1080+
#### Perbaiki mutasi menggunakan metode nonmutatif {/*fix-the-mutations-using-non-mutative-methods*/}
10811081

1082-
In this example, all of the event handlers in `App.js` use mutation. As a result, editing and deleting todos doesn't work. Rewrite `handleAddTodo`, `handleChangeTodo`, and `handleDeleteTodo` to use the non-mutative methods:
1082+
Pada contoh ini, semua *event handler* di App.js menggunakan mutasi. Akibatnya, mengedit dan menghapus todos tidak berfungsi. Tulis ulang `handleAddTodo`, `handleChangeTodo`, dan `handleDeleteTodo` untuk menggunakan metode *non-mutatif*:
10831083

10841084
<Sandpack>
10851085

@@ -1146,14 +1146,14 @@ export default function AddTodo({ onAddTodo }) {
11461146
return (
11471147
<>
11481148
<input
1149-
placeholder="Add todo"
1149+
placeholder="Tambah todo"
11501150
value={title}
11511151
onChange={e => setTitle(e.target.value)}
11521152
/>
11531153
<button onClick={() => {
11541154
setTitle('');
11551155
onAddTodo(title);
1156-
}}>Add</button>
1156+
}}>Tambah</button>
11571157
</>
11581158
)
11591159
}
@@ -1197,7 +1197,7 @@ function Task({ todo, onChange, onDelete }) {
11971197
});
11981198
}} />
11991199
<button onClick={() => setIsEditing(false)}>
1200-
Save
1200+
Simpan
12011201
</button>
12021202
</>
12031203
);
@@ -1225,7 +1225,7 @@ function Task({ todo, onChange, onDelete }) {
12251225
/>
12261226
{todoContent}
12271227
<button onClick={() => onDelete(todo.id)}>
1228-
Delete
1228+
Hapus
12291229
</button>
12301230
</label>
12311231
);
@@ -1242,7 +1242,7 @@ ul, li { margin: 0; padding: 0; }
12421242

12431243
<Solution>
12441244

1245-
In `handleAddTodo`, you can use the array spread syntax. In `handleChangeTodo`, you can create a new array with `map`. In `handleDeleteTodo`, you can create a new array with `filter`. Now the list works correctly:
1245+
Pada `handleAddTodo`, Anda bisa menggunakan sintaksis penyebaran senarai. Pada `handleChangeTodo`, Anda dapat membuat senarai baru dengan `map`. Pada `handleDeleteTodo`, Anda dapat membuat senarai baru dengan `filter`. Sekarang daftar berfungsi dengan benar:
12461246

12471247
<Sandpack>
12481248

@@ -1313,14 +1313,14 @@ export default function AddTodo({ onAddTodo }) {
13131313
return (
13141314
<>
13151315
<input
1316-
placeholder="Add todo"
1316+
placeholder="Tambah todo"
13171317
value={title}
13181318
onChange={e => setTitle(e.target.value)}
13191319
/>
13201320
<button onClick={() => {
13211321
setTitle('');
13221322
onAddTodo(title);
1323-
}}>Add</button>
1323+
}}>Tambah</button>
13241324
</>
13251325
)
13261326
}
@@ -1364,7 +1364,7 @@ function Task({ todo, onChange, onDelete }) {
13641364
});
13651365
}} />
13661366
<button onClick={() => setIsEditing(false)}>
1367-
Save
1367+
Simpan
13681368
</button>
13691369
</>
13701370
);
@@ -1392,7 +1392,7 @@ function Task({ todo, onChange, onDelete }) {
13921392
/>
13931393
{todoContent}
13941394
<button onClick={() => onDelete(todo.id)}>
1395-
Delete
1395+
Hapus
13961396
</button>
13971397
</label>
13981398
);
@@ -1410,9 +1410,9 @@ ul, li { margin: 0; padding: 0; }
14101410
</Solution>
14111411

14121412

1413-
#### Fix the mutations using Immer {/*fix-the-mutations-using-immer*/}
1413+
#### Perbaiki mutasi menggunakan Immer {/*fix-the-mutations-using-immer*/}
14141414

1415-
This is the same example as in the previous challenge. This time, fix the mutations by using Immer. For your convenience, `useImmer` is already imported, so you need to change the `todos` state variable to use it.
1415+
Ini adalah contoh yang sama seperti pada tantangan sebelumnya. Kali ini, perbaiki mutasi dengan menggunakan Immer. Untuk kemudahan Anda, `useImmer` sudah diimpor, jadi Anda perlu mengubah variabel state `todos` untuk menggunakannya.
14161416

14171417
<Sandpack>
14181418

@@ -1480,14 +1480,14 @@ export default function AddTodo({ onAddTodo }) {
14801480
return (
14811481
<>
14821482
<input
1483-
placeholder="Add todo"
1483+
placeholder="Tambah todo"
14841484
value={title}
14851485
onChange={e => setTitle(e.target.value)}
14861486
/>
14871487
<button onClick={() => {
14881488
setTitle('');
14891489
onAddTodo(title);
1490-
}}>Add</button>
1490+
}}>Tambah</button>
14911491
</>
14921492
)
14931493
}
@@ -1531,7 +1531,7 @@ function Task({ todo, onChange, onDelete }) {
15311531
});
15321532
}} />
15331533
<button onClick={() => setIsEditing(false)}>
1534-
Save
1534+
Simpan
15351535
</button>
15361536
</>
15371537
);
@@ -1559,7 +1559,7 @@ function Task({ todo, onChange, onDelete }) {
15591559
/>
15601560
{todoContent}
15611561
<button onClick={() => onDelete(todo.id)}>
1562-
Delete
1562+
Hapus
15631563
</button>
15641564
</label>
15651565
);
@@ -1594,7 +1594,7 @@ ul, li { margin: 0; padding: 0; }
15941594

15951595
<Solution>
15961596

1597-
With Immer, you can write code in the mutative fashion, as long as you're only mutating parts of the `draft` that Immer gives you. Here, all mutations are performed on the `draft` so the code works:
1597+
Dengan Immer, Anda dapat menulis kode dengan gaya yang dapat bermutasi, selama Anda hanya memutasi bagian-bagian dari `draft` yang diberikan oleh Immer. Di sini, semua mutasi dilakukan pada `draft`, jadi kode berfungsi:
15981598

15991599
<Sandpack>
16001600

@@ -1668,14 +1668,14 @@ export default function AddTodo({ onAddTodo }) {
16681668
return (
16691669
<>
16701670
<input
1671-
placeholder="Add todo"
1671+
placeholder="Tambah todo"
16721672
value={title}
16731673
onChange={e => setTitle(e.target.value)}
16741674
/>
16751675
<button onClick={() => {
16761676
setTitle('');
16771677
onAddTodo(title);
1678-
}}>Add</button>
1678+
}}>Tambah</button>
16791679
</>
16801680
)
16811681
}
@@ -1719,7 +1719,7 @@ function Task({ todo, onChange, onDelete }) {
17191719
});
17201720
}} />
17211721
<button onClick={() => setIsEditing(false)}>
1722-
Save
1722+
Simpan
17231723
</button>
17241724
</>
17251725
);
@@ -1747,7 +1747,7 @@ function Task({ todo, onChange, onDelete }) {
17471747
/>
17481748
{todoContent}
17491749
<button onClick={() => onDelete(todo.id)}>
1750-
Delete
1750+
Hapus
17511751
</button>
17521752
</label>
17531753
);
@@ -1780,9 +1780,9 @@ ul, li { margin: 0; padding: 0; }
17801780

17811781
</Sandpack>
17821782

1783-
You can also mix and match the mutative and non-mutative approaches with Immer.
1783+
Anda juga dapat mencampur dan mencocokkan pendekatan *mutatif* dan *non-mutatif* dengan Immer.
17841784

1785-
For example, in this version `handleAddTodo` is implemented by mutating the Immer `draft`, while `handleChangeTodo` and `handleDeleteTodo` use the non-mutative `map` and `filter` methods:
1785+
Misalnya, dalam versi ini `handleAddTodo` diimplementasikan dengan mengubah `draft` Immer, sedangkan `handleChangeTodo` dan `handleDeleteTodo` menggunakan metode `map` dan `filter` *non-mutatif*:
17861786

17871787
<Sandpack>
17881788

@@ -1853,14 +1853,14 @@ export default function AddTodo({ onAddTodo }) {
18531853
return (
18541854
<>
18551855
<input
1856-
placeholder="Add todo"
1856+
placeholder="Tambah todo"
18571857
value={title}
18581858
onChange={e => setTitle(e.target.value)}
18591859
/>
18601860
<button onClick={() => {
18611861
setTitle('');
18621862
onAddTodo(title);
1863-
}}>Add</button>
1863+
}}>Tambah</button>
18641864
</>
18651865
)
18661866
}
@@ -1904,7 +1904,7 @@ function Task({ todo, onChange, onDelete }) {
19041904
});
19051905
}} />
19061906
<button onClick={() => setIsEditing(false)}>
1907-
Save
1907+
Simpan
19081908
</button>
19091909
</>
19101910
);
@@ -1932,7 +1932,7 @@ function Task({ todo, onChange, onDelete }) {
19321932
/>
19331933
{todoContent}
19341934
<button onClick={() => onDelete(todo.id)}>
1935-
Delete
1935+
Hapus
19361936
</button>
19371937
</label>
19381938
);
@@ -1965,7 +1965,7 @@ ul, li { margin: 0; padding: 0; }
19651965

19661966
</Sandpack>
19671967

1968-
With Immer, you can pick the style that feels the most natural for each separate case.
1968+
Dengan Immer, Anda dapat memilih gaya yang terasa paling alami untuk setiap casing terpisah.
19691969

19701970
</Solution>
19711971

0 commit comments

Comments
 (0)