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: src/content/learn/escape-hatches.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -21,15 +21,15 @@ Beberapa komponen-komponen Anda mungkin membutuhkan kendali dan sinkronisasi den
21
21
22
22
</YouWillLearn>
23
23
24
-
## Referencing values with refs {/*referencing-values-with-refs*/}
24
+
## Mereferensikan nilai menggunakan refs {/*referencing-values-with-refs*/}
25
25
26
-
When you want a component to "remember" some information, but you don't want that information to [trigger new renders](/learn/render-and-commit), you can use a*ref*:
26
+
Ketika Anda ingin sebuah komponen "mengingat" beberapa informasi, tapi Anda tidak ingin informasi tersebut [memicu *render* baru](/learn/render-and-commit), Anda dapat menggunakan*ref*:
27
27
28
28
```js
29
29
constref=useRef(0);
30
30
```
31
31
32
-
Like state, refs are retained by React between re-renders. However, setting state re-renders a component. Changing a ref does not! You can access the current value of that ref through the `ref.current` property.
32
+
Sama seperti *state*, *refs* disimpan oleh React diantara pe-*render*-an ulang. Namun, mengatur *state* menyebabkan komponen di-*render* ulang. Mengganti sebuah *ref* tidak! Anda dapat mengakses nilai saat ini dari *ref* tersebut melalui properti `ref.current`.
33
33
34
34
<Sandpack>
35
35
@@ -41,24 +41,24 @@ export default function Counter() {
41
41
42
42
functionhandleClick() {
43
43
ref.current=ref.current+1;
44
-
alert('You clicked'+ref.current+'times!');
44
+
alert('Anda mengeklik'+ref.current+'kali!');
45
45
}
46
46
47
47
return (
48
48
<button onClick={handleClick}>
49
-
Click me!
49
+
Klik saya!
50
50
</button>
51
51
);
52
52
}
53
53
```
54
54
55
55
</Sandpack>
56
56
57
-
A ref is like a secret pocket of your component that React doesn't track. For example, you can use refs to store [timeout IDs](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#return_value), [DOM elements](https://developer.mozilla.org/en-US/docs/Web/API/Element), and other objects that don't impact the component's rendering output.
57
+
*Ref* seperti sebuah kantong rahasia dari komponen Anda yang tidak dilacak oleh React. Misalkan, Anda dapat menggunakan *refs* untuk menyimpan [*timeout IDs*](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#return_value), [elemen-elemen DOM](https://developer.mozilla.org/en-US/docs/Web/API/Element), dan objek lainnya yang tidak memengaruhi hasil *render* sebuah komponen.
Read**[Referencing Values with Refs](/learn/referencing-values-with-refs)**to learn how to use refs to remember information.
61
+
Baca**[Mereferensikan Nilai menggunakan Refs](/learn/referencing-values-with-refs)**untuk mempelajari bagaimana menggunakan *refs* untuk mengingat informasi.
0 commit comments