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
Call `useDebugValue`at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value:
23
+
قم باستدعاء `useDebugValue`في المستوى الأعلي من [خطافك المخصص](/learn/reusing-logic-with-custom-hooks) لعرض قيمة تصحيح قابلة للقراءة:
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
+
[اطلع على المزيد من الأمثلة بالأسفل.](#usage)
36
36
37
-
#### Parameters {/*parameters*/}
37
+
#### المعاملات (parameters) {/*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`: القيمة التي تريد عرضها في أدوات مطور React. يمكن أن تكون من أي نوع.
40
+
* **اختياري** `format`: دالة تنسيق. عند فحص المكون، ستقوم أدوات المطور باستدعاء دالة التنسيق مع `value`كمعامل، ثم يتم عرض القيمة التي تم إرجاعها (والتي قد تحتوي على أي نوع). إذا لم تحدد دالة التنسيق، سيتم عرض القيمة الأصلية من المعامل `value`.
41
41
42
-
#### Returns {/*returns*/}
42
+
#### العائدات {/*returns*/}
43
43
44
-
`useDebugValue`does not return anything.
44
+
`useDebugValue`لا يعيد أي شيء.
45
45
46
-
## Usage {/*usage*/}
46
+
## الاستخدام {/*usage*/}
47
47
48
-
### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/}
48
+
### إضافة تصنيف إلي خطاف مخصص {/*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
+
قم باستدعاء `useDebugValue`في المستوى الأعلي من [خطافك المخصص](/learn/reusing-logic-with-custom-hooks) لعرض <CodeStep step={1}>قيمة تصحيح</CodeStep> قابلة للقرائة في [أدوات مطور React.](/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
+
هذا يتيح للمكونات التي تستدعى `useOnlineStatus`أن تحمل تصنيف مثل `OnlineStatus:"Online"`عندما تقوم بفحصها:
63
63
64
-

64
+

65
65
66
-
Without the`useDebugValue` call, only the underlying data (in this example,`true`) would be displayed.
66
+
بدون استدعاء`useDebugValue`، سيتم عرض البيانات الأساسية فقط دون أي تصنيف (في هذا المثال،`true`).
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
+
لا تضف قيم تصحيح إلى كل خطاف مخصص. يعد مفيدًا أكثر للخطافات المخصصة التي تشكل جزءا من المكتبات المشتركة والتي تحتوي على هيكل بيانات داخلي معقد يصعب فحصه.
107
107
108
108
</Note>
109
109
110
110
---
111
111
112
-
### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/}
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
+
ستتلقى دالة التنسيق الخاصة بك <CodeStep step={1}>قيمة التصحيح</CodeStep> كمعامل ويجب أن تعيد <CodeStep step={2}>قيمة عرض منسقة</CodeStep>. عندما يتم فحص مكونك، ستقوم أدوات مطور React باستدعاء هذه الدالة وتعرض القيمة المنسقة التي تم إرجاعها.
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
+
وهذا يتيح لك تجنب تنفيذ منطق التنسيق باهظ التكلفة ما لم يتم فحص المكون فعليا. على سبيل المثال, إذا كان المتغير `date`يحمل قيمة تاريخ, فإن استخدام قيمة التصحيح يساعد في تجنب استدعاء دالة `toDateString()`عليها في كل عملية عرض.
0 commit comments