Skip to content

Commit 68cdbf2

Browse files
committed
docs: translate first section
1 parent 7132cd8 commit 68cdbf2

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/content/learn/keeping-components-pure.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,36 @@ Beberapa fungsi JavaScript bersifat murni, yaitu hanya melakukan kalkulasi. Deng
1616

1717
</YouWillLearn>
1818

19-
## Purity: Components as formulas {/*purity-components-as-formulas*/}
19+
## Kemurnian: Komponen sebagai rumus {/*purity-components-as-formulas*/}
2020

21-
In computer science (and especially the world of functional programming), [a pure function](https://wikipedia.org/wiki/Pure_function) is a function with the following characteristics:
21+
Dalam ilmu komputer, terutama di dunia pemrograman fungsional, [fungsi murni](https://wikipedia.org/wiki/Pure_function) adalah sebuah fungsi yang memenuhi kriteria berikut:
2222

23-
* **It minds its own business.** It does not change any objects or variables that existed before it was called.
24-
* **Same inputs, same output.** Given the same inputs, a pure function should always return the same result.
23+
* **Dia hanya mengurus dirinya sendiri.** Dia tidak mengubah objek atau variabel yang ada sebelum dia dipanggil.
24+
* **Masukan yang sama, luaran yang sama.** Untuk masukan yang sama, fungsi murni akan selalu menghasilkan luaran yang sama.
2525

26-
You might already be familiar with one example of pure functions: formulas in math.
26+
Anda mungkin sudah akrab dengan salah satu contoh fungsi murni, yaitu rumus-rumus dalam matematika.
2727

28-
Consider this math formula: <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>.
28+
Perhatikan rumus ini: <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>.
2929

30-
If <Math><MathI>x</MathI> = 2</Math> then <Math><MathI>y</MathI> = 4</Math>. Always.
30+
Jika <Math><MathI>x</MathI> = 2</Math>, <Math><MathI>y</MathI> = 4</Math>. Selalu.
3131

32-
If <Math><MathI>x</MathI> = 3</Math> then <Math><MathI>y</MathI> = 6</Math>. Always.
32+
Jika <Math><MathI>x</MathI> = 3</Math>, <Math><MathI>y</MathI> = 6</Math>. Selalu.
3333

34-
If <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> won't sometimes be <Math>9</Math> or <Math>–1</Math> or <Math>2.5</Math> depending on the time of day or the state of the stock market.
34+
Jika <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> tidak mungkin bernilai <Math>9</Math> ataupun <Math>–1</Math> ataupun <Math>2.5</Math> hanya karena ada pergantian hari atau pergerakan bursa saham.
3535

36-
If <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> and <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> will _always_ be <Math>6</Math>.
36+
Jika <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> dan <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> akan *selalu* bernilai <Math>6</Math>.
3737

38-
If we made this into a JavaScript function, it would look like this:
38+
Jika kita mengonversi rumus ini menjadi fungsi JavaScript, fungsi tersebut akan terlihat seperti ini:
3939

4040
```js
4141
function double(number) {
4242
return 2 * number;
4343
}
4444
```
4545

46-
In the above example, `double` is a **pure function.** If you pass it `3`, it will return `6`. Always.
46+
Pada contoh di atas, `double` adalah sebuah **fungsi murni**. Jika Anda masukkan `3`, fungsi itu akan mengembalikan `6`. Selalu.
4747

48-
React is designed around this concept. **React assumes that every component you write is a pure function.** This means that React components you write must always return the same JSX given the same inputs:
48+
React dibuat berdasarkan konsep ini. **React berasumsi kalau setiap komponen yang Anda buat adalah fungsi murni**. Ini berarti komponen React yang Anda buat harus selalu menghasilkan JSX yang sama jika diberikan masukan yang sama:
4949

5050
<Sandpack>
5151

@@ -75,15 +75,15 @@ export default function App() {
7575

7676
</Sandpack>
7777

78-
When you pass `drinkers={2}` to `Recipe`, it will return JSX containing `2 cups of water`. Always.
78+
Jika Anda memberikan `drinkers={2}` ke `Recipe`, komponen tersebut akan mengembalikan JSX yang berisi `2 cups of water`. Selalu.
7979

80-
If you pass `drinkers={4}`, it will return JSX containing `4 cups of water`. Always.
80+
Jika Anda memberikan `drinkers={4}`, komponen tersebut akan mengembalikan JSX yang berisi `4 cups of water`. Selalu.
8181

82-
Just like a math formula.
82+
Seperti rumus matematika.
8383

84-
You could think of your components as recipes: if you follow them and don't introduce new ingredients during the cooking process, you will get the same dish every time. That "dish" is the JSX that the component serves to React to [render.](/learn/render-and-commit)
84+
Anda bisa menganggap komponen Anda sebagai resep: jika Anda mengikuti resep tersebut dan tidak menambahkan bahan apapun dalam proses pemasakan, Anda akan selalu mendapatkan makanan yang sama. "Makanan" itu adalah JSX yang diserahkan sebuah komponen ke React untuk di-[*render*](/learn/render-and-commit).
8585

86-
<Illustration src="/images/docs/illustrations/i_puritea-recipe.png" alt="A tea recipe for x people: take x cups of water, add x spoons of tea and 0.5x spoons of spices, and 0.5x cups of milk" />
86+
<Illustration src="/images/docs/illustrations/i_puritea-recipe.png" alt="Sebuah resep teh untuk x orang: membutuhkan x gelas air, tambahkan teh sebanyak x sendok, tambahkan rempah sebanyak 0,5 sendok, dan 0,5 gelas susu" />
8787

8888
## Side Effects: (un)intended consequences {/*side-effects-unintended-consequences*/}
8989

0 commit comments

Comments
 (0)