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/reference/react/useDebugValue.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: useDebugValue
4
4
5
5
<Intro>
6
6
7
-
`useDebugValue`is a React Hook that lets you add a label to a custom Hook in[React DevTools.](/learn/react-developer-tools)
7
+
`useDebugValue`merupakan React Hook yang memungkinkan Anda untuk menambahkan label ke sebuah Hook kustom di dalam[React DevTools.](/learn/react-developer-tools)
Call`useDebugValue`at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value:
23
+
Panggil`useDebugValue`di bagian atas [Hook kustom](/learn/reusing-logic-with-custom-hooks) Anda untuk manampilkan nilai *debug* yang dapat dibaca:
24
24
25
25
```js
26
26
import { useDebugValue } from'react';
@@ -32,22 +32,22 @@ function useOnlineStatus() {
32
32
}
33
33
```
34
34
35
-
[See more examples below.](#usage)
35
+
[Lihat lebih banyak contoh di bawah ini.](#usage)
36
36
37
-
#### Parameters {/*parameters*/}
37
+
#### Parameter {/*parameters*/}
38
38
39
-
* `value`: The value you want to display in React DevTools. It can have any type.
40
-
* **optional** `format`: A formatting function. When the component is inspected, React DevTools will call the formatting function with the `value`as the argument, and then display the returned formatted value (which may have any type). If you don't specify the formatting function, the original `value`itself will be displayed.
39
+
* `value`: Nilai yang Anda inginkan untuk ditampilkan di dalam React DevTools. Nilai tersebut dapat memiliki tipe apa pun.
40
+
* `format` **opsional**: Fungsi untuk pemformatan. Ketika komponen diperiksa, React DevTools akan memanggil fungsi pemformatan dengan `value`sebagai argumennya, dan kemudian menampilkan nilai kembalian yang telah diformat (yang mungkin memiliki jenis apapun). Jika Anda tidak menentukan fungsi pemformatan, `value`asli itu sendiri yang akan ditampilkan.
41
41
42
-
#### Returns {/*returns*/}
42
+
#### Kembalian {/*returns*/}
43
43
44
-
`useDebugValue`does not return anything.
44
+
`useDebugValue`tidak mengembalikan apapun.
45
45
46
-
## Usage {/*usage*/}
46
+
## Penggunaan {/*usage*/}
47
47
48
-
### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/}
48
+
### Menambahkan sebuah label ke sebuah Hook kustom {/*adding-a-label-to-a-custom-hook*/}
49
49
50
-
Call`useDebugValue`at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable <CodeStep step={1}>debug value</CodeStep> for [React DevTools.](/learn/react-developer-tools)
50
+
Panggil`useDebugValue`pada bagian atas [Hook kustom](/learn/reusing-logic-with-custom-hooks) Anda untuk menampilkan <CodeStep step={1}>nilai debug</CodeStep> yang dapat dibaca untuk [React DevTools.](/learn/react-developer-tools)
51
51
52
52
```js [[1, 5, "isOnline ? 'Online' : 'Offline'"]]
53
53
import { useDebugValue } from'react';
@@ -59,11 +59,11 @@ function useOnlineStatus() {
59
59
}
60
60
```
61
61
62
-
This gives components calling `useOnlineStatus`a label like`OnlineStatus:"Online"`when you inspect them:
62
+
Hal ini akan mengakibatkan komponen yang memanggil `useOnlineStatus`memiliki label seperti`OnlineStatus:"Online"`ketika Anda memeriksanya:
63
63
64
-

64
+

65
65
66
-
Without the`useDebugValue` call, only the underlying data (in this example, `true`) would be displayed.
66
+
Tanpa panggilan`useDebugValue`, hanya data yang mendasarinya (dalam contoh ini, `true`) yang akan ditampilkan.
67
67
68
68
<Sandpack>
69
69
@@ -103,20 +103,20 @@ function subscribe(callback) {
103
103
104
104
<Note>
105
105
106
-
Don't add debug values to every custom Hook. It's most valuable for custom Hooks that are part of shared libraries and that have a complex internal data structure that's difficult to inspect.
106
+
Jangan menambahkan nilai *debug* untuk setiap Hook kustom. Nilai tersebut paling berharga untuk Hooks kustom yang merupakan bagian dari pustaka bersama dan memiliki struktur data internal yang kompleks sehingga sulit untuk diperiksa.
107
107
108
108
</Note>
109
109
110
110
---
111
111
112
-
### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/}
112
+
### Menunda pemformatan nilai *debug* {/*deferring-formatting-of-a-debug-value*/}
113
113
114
-
You can also pass a formatting function as the second argument to`useDebugValue`:
114
+
Anda juga bisa meneruskan fungsi pemformatan sebagai argumen kedua ke`useDebugValue`:
Your formatting function will receive the <CodeStep step={1}>debug value</CodeStep> as a parameter and should return a <CodeStep step={2}>formatted display value</CodeStep>. When your component is inspected, React DevTools will call this function and display its result.
120
+
Fungsi pemformatan Anda akan menerima <CodeStep step={1}>nilai debug</CodeStep> sebagai sebuah parameter dan akan mengembalikan sebuah <CodeStep step={2}>nilai tampilan yang telah diformat</CodeStep>. Ketika komponen Anda diperiksa, React DevTools akan memanggil fungsi ini dan menampilkan hasilnya.
121
121
122
-
This lets you avoid running potentially expensive formatting logic unless the component is actually inspected. For example, if`date`is a Date value, this avoids calling`toDateString()`on it for every render.
122
+
Ini memungkinkan Anda menghindari menjalankan logika pemformatan yang berpotensi mahal/berat (*potentially expensive formatting logic*) kecuali komponen benar-benar diperiksa. Sebagai contoh, jika`date`merupakan sebuah nilai *Date*, ini menghindari pemanggilan`toDateString()`pada setiap render.
0 commit comments