-
Notifications
You must be signed in to change notification settings - Fork 110
[Done] Translating useDebugValue
#489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AhmedBaset
merged 3 commits into
reactjs:main
from
remahmoud:add-usedebugvalue-page-translation
Jun 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ title: useDebugValue | |
|
||
<Intro> | ||
|
||
`useDebugValue` is a React Hook that lets you add a label to a custom Hook in [React DevTools.](/learn/react-developer-tools) | ||
`useDebugValue` هو خطاف React يمكنك من إضافة تصنيف إلي خطاف مخصص في [React DevTools.](/learn/react-developer-tools) | ||
|
||
```js | ||
useDebugValue(value, format?) | ||
|
@@ -16,11 +16,11 @@ useDebugValue(value, format?) | |
|
||
--- | ||
|
||
## Reference {/*reference*/} | ||
## المرجع {/*reference*/} | ||
|
||
### `useDebugValue(value, format?)` {/*usedebugvalue*/} | ||
|
||
Call `useDebugValue` at the top level of your [custom Hook](/learn/reusing-logic-with-custom-hooks) to display a readable debug value: | ||
قم باستدعاء `useDebugValue` في المستوى الأعلي من [الخطاف المخصص](/learn/reusing-logic-with-custom-hooks) لعرض قيمة تصحيح قابلة للقراءة: | ||
|
||
```js | ||
import { useDebugValue } from 'react'; | ||
|
@@ -34,20 +34,20 @@ function useOnlineStatus() { | |
|
||
[See more examples below.](#usage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ترجم هذه |
||
|
||
#### Parameters {/*parameters*/} | ||
#### المعاملات (parameters) {/*parameters*/} | ||
|
||
* `value`: The value you want to display in React DevTools. It can have any type. | ||
* **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. | ||
* `value`: القيمة التي تريد عرضها في React DevTools. يمكن أن يكون لها أي نوع. | ||
* **اختياري** `format`: دالة تنسيق. عند فحص المكون، React DevTools ستقوم باستدعاء دالة التنسيق مع `value` كمعامل، ثم يتم عرض القيمة التي تم إرجاعها (والتي قد تحتوي على أي نوع). إذا لم تحدد دالة التنسيق، سيتم عرض القيمة الأصلية من المعامل `value`. | ||
|
||
#### Returns {/*returns*/} | ||
#### العائدات {/*returns*/} | ||
|
||
`useDebugValue` does not return anything. | ||
`useDebugValue` لا يعيد أي شيء. | ||
|
||
## Usage {/*usage*/} | ||
## الاستخدام {/*usage*/} | ||
|
||
### Adding a label to a custom Hook {/*adding-a-label-to-a-custom-hook*/} | ||
### إضافة تصنيف إلي خطاف مخصص {/*adding-a-label-to-a-custom-hook*/} | ||
|
||
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) | ||
قم باستدعاء `useDebugValue` في المستوى الأعلي من [الخطاف المخصص](/learn/reusing-logic-with-custom-hooks) لعرض <CodeStep step={1}>debug value</CodeStep> قابلة للقرائة في [React DevTools.](/learn/react-developer-tools) | ||
|
||
```js [[1, 5, "isOnline ? 'Online' : 'Offline'"]] | ||
import { useDebugValue } from 'react'; | ||
|
@@ -59,11 +59,11 @@ function useOnlineStatus() { | |
} | ||
``` | ||
|
||
This gives components calling `useOnlineStatus` a label like `OnlineStatus: "Online"` when you inspect them: | ||
هذا يتيح للمكونات التي تستدعى `useOnlineStatus` أن تحمل تصنيف مثل `OnlineStatus: "Online"` عندما تقوم بفحصها: | ||
|
||
 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ترجم هذا |
||
|
||
Without the `useDebugValue` call, only the underlying data (in this example, `true`) would be displayed. | ||
بدون استدعاء `useDebugValue`، سيتم عرض فقط البيانات الأساسية دون أي تصنيف (في هذا المثال، `true`). | ||
|
||
<Sandpack> | ||
|
||
|
@@ -103,20 +103,20 @@ function subscribe(callback) { | |
|
||
<Note> | ||
|
||
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. | ||
لا تضيف قيم تصحيح إلى كل خطاف مخصص. تعد أكثر قيمة للخطافات المخصصة التي تشكل جزءا من المكتبات المشتركة والتي تحتوي على هيكل بيانات داخلي معقد يصعب فحصه. | ||
|
||
</Note> | ||
|
||
--- | ||
|
||
### Deferring formatting of a debug value {/*deferring-formatting-of-a-debug-value*/} | ||
### تأجيل التنسيق لقيمة التصحيح (debug value) {/*deferring-formatting-of-a-debug-value*/} | ||
|
||
You can also pass a formatting function as the second argument to `useDebugValue`: | ||
يمكنك أيضا تمرير دالة تنسيق كمعامل (parameter) ثاني إلي `useDebugValue`: | ||
|
||
```js [[1, 1, "date", 18], [2, 1, "date.toDateString()"]] | ||
useDebugValue(date, date => date.toDateString()); | ||
``` | ||
|
||
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. | ||
ستتلقى دالة التنسيق الخاصة بك <CodeStep step={1}>debug value</CodeStep> كمعامل ويجب أن تعيد <CodeStep step={2}>قيمة عرض منسقة</CodeStep>. عندما يتم فحص مكونك، ستقوم React DevTools باستدعاء هذه الدالة وتعرض القيمة المنسقة التي تم إرجاعها. | ||
|
||
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. | ||
وهذا يتيح لك تجنب تنفيذ منطق التنسيق باهظ التكلفة ما لم يتم فحص المكون فعليا. على سبيل المثال, إذا كان المتغير `date` يحمل قيمة تاريخ, فإن استخدام قيمة التصحيح يساعد في تجنب استدعاء دالة `toDateString()` عليها في كل عملية عرض. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
إلي => إلى
أدوات مطور React