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/describing-the-ui.md
+46-46Lines changed: 46 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,29 @@
1
1
---
2
-
title: Describing the UI
2
+
title: وصف واجهات المستخدم (UI)
3
3
---
4
4
5
5
<Intro>
6
6
7
-
React is a JavaScript library for rendering user interfaces (UI). UI is built from small units like buttons, text, and images. React lets you combine them into reusable, nestable *components.* From web sites to phone apps, everything on the screen can be broken down into components. In this chapter, you'll learn to create, customize, and conditionally display React components.
7
+
تعد React من مكتبات JavaScript المخصَّصة لبناء واجهات المستخدم (UI). يتم بناء واجهات المستخدم من وحدات صغيرة مثل الأزرار والنصوص والصور. تسمح لك React بتجميع هذه العناصر في مكونات (Components) يمكن إعادة استخدامها أو تضمينها داخل بعضها البعض. من مواقع الويب إلى تطبيقات الهاتف الجوال يمكن تقسم كل شئ إلى مكونات. في هذا الفصل، سوف تتعلم كيفية إنشاء وتعديل وعرض مكونات حسب الشروط.
8
8
9
9
</Intro>
10
10
11
11
<YouWillLearnisChapter={true}>
12
12
13
-
*[How to write your first React component](/learn/your-first-component)
14
-
*[When and how to create multi-component files](/learn/importing-and-exporting-components)
15
-
*[How to add markup to JavaScript with JSX](/learn/writing-markup-with-jsx)
16
-
*[How to use curly braces with JSX to access JavaScript functionality from your components](/learn/javascript-in-jsx-with-curly-braces)
17
-
*[How to configure components with props](/learn/passing-props-to-a-component)
18
-
*[How to conditionally render components](/learn/conditional-rendering)
19
-
*[How to render multiple components at a time](/learn/rendering-lists)
20
-
*[How to avoid confusing bugs by keeping components pure](/learn/keeping-components-pure)
13
+
*[كيفية كتابة أول مكون React لك](/learn/your-first-component)
14
+
*[متى وكيف تنشأ ملفات تحتوى على أكثر من مكون](/learn/importing-and-exporting-components)
15
+
*[كيفية إضافة ترميزات (Markup) إلى JavaScript باستخدام JSX](/learn/writing-markup-with-jsx)
16
+
*[كيفية استخدام الأقواس المجعدة في JSX لاستخدام وظائف JavaScript في مكوناتك (Components)](/learn/javascript-in-jsx-with-curly-braces)
17
+
*[كيفية إعداد المكونات باستخدام الخصائص (Props)](/learn/passing-props-to-a-component)
18
+
*[(Conditional rendering) كيفية عرض المكونات بشكل مشروط](/learn/conditional-rendering)
19
+
*[كيفية عرض أكثر من مكون مرة واحدة](/learn/rendering-lists)
20
+
*[كيفية تجنب الثغرات المحيرة عن طريق الحفاظ على المكونات نقية](/learn/keeping-components-pure)
21
21
22
22
</YouWillLearn>
23
23
24
-
## Your first component {/*your-first-component*/}
24
+
## أول مكون لك {/*your-first-component*/}
25
25
26
-
React applications are built from isolated pieces of UI called *components*. A React component is a JavaScript function that you can sprinkle with markup. Components can be as small as a button, or as large as an entire page. Here is a `Gallery`component rendering three `Profile` components:
26
+
يتم بناء تطبيقات React باستخدام قطع معزولة من واجهات المستخدم تسمى مكونات. المكون في React هو عبارة عن دالة JavaScript التى يمكنك إضافة ترميزات إليها. المكونات يمكن أن تكون صغيرة كزرار أو كبيرة كصفحة كاملة. هنا المكون `Gallery`يقوم بعرض ثلاث مكونات `Profile`:
You can declare many components in one file, but large files can get difficult to navigate. To solve this, you can *export*a component into its own file, and then *import*that component from another file:
66
+
يمكنك تعريف أكثر من مكون في ملف واحد، ولكن الملفات الكبيرة يمكن أن تصبح صعبة التصفح. لحل هذه المشكلة يمكنك أن تصدر *export*مكون من الملف الخاص به، ثم استخدام *import*لتستخدم هذا المكون في ملف آخر:
Read**[Importing and Exporting Components](/learn/importing-and-exporting-components)**to learn how to split components into their own files.
115
+
اقرأ**[استيراد وتصدير المكونات](/learn/importing-and-exporting-components)**لتتعلم كيفية تقسيم المكونات إلى ملفات خاصة بها.
116
116
117
117
</LearnMore>
118
118
119
-
## Writing markup with JSX {/*writing-markup-with-jsx*/}
119
+
## كتابة ترميزات (Markup) باستخدام JSX {/*writing-markup-with-jsx*/}
120
120
121
-
Each React component is a JavaScript function that may contain some markup that React renders into the browser. React components use a syntax extension called JSX to represent that markup. JSX looks a lot like HTML, but it is a bit stricter and can display dynamic information.
121
+
كل مكون في React عبارة عن دالة JavaScript التى يمكن أن تحتوي على بعض الترميزات التي يمكن لـ React أن تعرضها في المتصفح. المكونات في React تستخدم صيغة معدلة تسمى JSX لكى تمثل هذه الترميزات. JSX تشبه HTML كثيرا، ولكنها صارمة قليلا وتستطيع أن تعرض محتوى ديناميكي.
122
122
123
-
If we paste existing HTML markup into a React component, it won't always work:
123
+
إذا قمنا بنسخ ترميزات HTML موجودة سابقا داخل مكون React، لن تعمل دائما:
124
124
125
125
<Sandpack>
126
126
@@ -149,7 +149,7 @@ img { height: 90px; }
149
149
150
150
</Sandpack>
151
151
152
-
If you have existing HTML like this, you can fix it using a [converter](https://transform.tools/html-to-jsx):
152
+
إذا كان لديك ترميزات HTML مثل هذه، يمكنك أن تصلحها باستخدام [محوّل](https://transform.tools/html-to-jsx):
153
153
154
154
<Sandpack>
155
155
@@ -181,13 +181,13 @@ img { height: 90px; }
181
181
182
182
<LearnMorepath="/learn/writing-markup-with-jsx">
183
183
184
-
Read**[Writing Markup with JSX](/learn/writing-markup-with-jsx)**to learn how to write valid JSX.
184
+
اقرأ**[كتابة ترميزات (Markup) باستخدام JSX](/learn/writing-markup-with-jsx)**لتتعلم كيفية كتابة JSX صحيحة
185
185
186
186
</LearnMore>
187
187
188
-
## JavaScript in JSX with curly braces {/*javascript-in-jsx-with-curly-braces*/}
188
+
## استخدام JavaScript في JSX باستخدام الأقواس المجعدة {/*javascript-in-jsx-with-curly-braces*/}
189
189
190
-
JSX lets you write HTML-like markup inside a JavaScript file, keeping rendering logic and content in the same place. Sometimes you will want to add a little JavaScript logic or reference a dynamic property inside that markup. In this situation, you can use curly braces in your JSX to "open a window" to JavaScript:
190
+
تتيح لك JSX أن تكتب ترميزات مشابهة إلى HTML بداخل ملفات JavaScript وأن تعرض محتوى وتبقى المنطق الخاص بالمكونات في نفس المكان. في بعض الأحيان، قد ترغب في إضافة بعض المنطق المكتوب باستخدام JavaScript أو الإشارة إلى خاصية ديناميكية داخل هذا الترميز. في هذا الموقف، يمكنك استخدام الأقواس المجعدة في JSX الخاص بك لفتح نافذة إلى JavaScript:
191
191
192
192
<Sandpack>
193
193
@@ -229,13 +229,13 @@ body > div > div { padding: 20px; }
Read **[JavaScript in JSX with Curly Braces](/learn/javascript-in-jsx-with-curly-braces)** to learn how to access JavaScript data from JSX.
232
+
اقرأ **[استخدام JavaScript في JSX باستخدام الأقواس المجعدة](/learn/javascript-in-jsx-with-curly-braces)** لتتعلم كيفية الوصول إلى بيانات JavaScript في JSX
233
233
234
234
</LearnMore>
235
235
236
-
## Passing props to a component {/*passing-props-to-a-component*/}
236
+
## تمرير الخصائص (Props) إلى مكون {/*passing-props-to-a-component*/}
237
237
238
-
React components use *props* to communicate with each other. Every parent component can pass some information to its child components by giving them props. Props might remind you of HTML attributes, but you can pass any JavaScript value through them, including objects, arrays, functions, and even JSX!
238
+
المكونات في React تتواصل مع بعضها البعض عن طريق الخصائص (Props). كل مكون أب يمكن له أن يمرر بعض المعلومات إلى المكونات الأبناء عن طريق إعطائهم خصائص. الخصائص يمكن أن تذكرك بـ"خصائص HTML"، ولكن يمكنك أن تمرر أي قيمة JavaScript عن طريقهم، هذا يمكن أن يكون كائن (object) أو مصفوفة (array) أو دالة function أو حتى JSX!
## العرض المشروط (Conditional rendering) {/*conditional-rendering*/}
318
318
319
-
Your components will often need to display different things depending on different conditions. In React, you can conditionally render JSX using JavaScript syntax like `if`statements,`&&`, and `? :` operators.
319
+
غالبًا ما تحتاج مكوناتك إلى عرض أشياء مختلفة تعتمد على شروط مختلفة. في React، يمكنك عرض JSX حسب شروط باستخدام صيغ شبيهه بـ JavaScript مثل التعبيرات الشرطية `if`والمعاملات`&&` و `condition ? if true : else`.
320
320
321
-
In this example, the JavaScript`&&`operator is used to conditionally render a checkmark:
321
+
في هذا المثال، معامل`&&`في JavaScript يستخدم لعرض علامة صح بشكل مشروط:
322
322
323
323
<Sandpack>
324
324
@@ -358,15 +358,15 @@ export default function PackingList() {
358
358
359
359
<LearnMore path="/learn/conditional-rendering">
360
360
361
-
Read **[Conditional Rendering](/learn/conditional-rendering)** to learn the different ways to render content conditionally.
361
+
اقرأ **[العرض المشروط (Conditional rendering)](/learn/conditional-rendering)** لتتعلم الطرق المختلفة لعرض المحتوى بشكل شرطي.
362
362
363
363
</LearnMore>
364
364
365
-
## Rendering lists {/*rendering-lists*/}
365
+
## عرض القوائم (lists) {/*rendering-lists*/}
366
366
367
-
You will often want to display multiple similar components from a collection of data. You can use JavaScript's `filter()`and`map()`with React to filter and transform your array of data into an array of components.
367
+
غالبًا ما سترغب في عرض عدة مكونات متشابهة من مجموعة البيانات. يمكن استخدام `filter()` و `map()` في JavaScript مع React لتصفية وتحويل مصفوفة البيانات الخاصة بك إلى مصفوفة من المكونات.
368
368
369
-
For each array item, you will need to specify a `key`. Usually, you will want to use an IDfrom the database as a `key`. Keyslet React keep track of each item's place in the list even if the list changes.
369
+
يتعين عليك تحديد مفتاح `key` لكل عنصر في المصفوفة. عادةً سترغب في استخدام ID من قاعدة البيانات كمفتاح `key`. يتيح المفتاح `key` إلى React أن تتبع مكان كل عنصر في القائمة حتى لو تغيرت القائمة.
370
370
371
371
<Sandpack>
372
372
@@ -458,26 +458,26 @@ h2 { font-size: 20px; }
458
458
459
459
<LearnMorepath="/learn/rendering-lists">
460
460
461
-
Read**[Rendering Lists](/learn/rendering-lists)**to learn how to render a list of components, and how to choose a key.
461
+
اقرأ**[عرض القوائم (lists)](/learn/rendering-lists)**لتتعلم كيفية عرض قوائم من المكونات، وكيفية اختيار مفتاح.
462
462
463
463
</LearnMore>
464
464
465
-
## Keeping components pure {/*keeping-components-pure*/}
465
+
## الحفاظ على المكونات نقية {/*keeping-components-pure*/}
466
466
467
-
Some JavaScript functions are *pure.* A pure function:
467
+
بعض دوال JavaScript *نقية*. الدالة النقية:
468
468
469
-
***Minds its own business.**It does not change any objects or variables that existed before it was called.
470
-
***Same inputs, same output.**Given the same inputs, a pure function should always return the same result.
469
+
***تهتم بشؤونها فقط.**لا تغيّر أي كائنات (objects) أو متغيرات (variables) كانت موجودة من قبل عند استدعائها.
470
+
***نفس المدخلات، نفس المخرجات.**يجب أن تعيد الدالة النقية دائمًا نفس النتيجة عندما تمرر لها نفس المُدخلات.
471
471
472
-
By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs and unpredictable behavior as your codebase grows. Here is an example of an impure component:
472
+
من خلال كتابة مكوناتك بشكل صارم، حيث تكون دوالا نقية فقط، يمكنك تجنب فئة كاملة من الأخطاء صعبة التفسير والسلوك غير المتوقع مع تطور قاعدة الكود (codebase) الخاصّة بك. هنا مثال على مكوّن غير نقي:
473
473
474
474
<Sandpack>
475
475
476
476
```js
477
477
let guest =0;
478
478
479
479
functionCup() {
480
-
//Bad: changing a preexisting variable!
480
+
//سيء: تعديل متغير موجود مسبقًا
481
481
guest = guest +1;
482
482
return<h2>Tea cup for guest #{guest}</h2>;
483
483
}
@@ -495,7 +495,7 @@ export default function TeaSet() {
495
495
496
496
</Sandpack>
497
497
498
-
You can make this component pure by passing a prop instead of modifying a preexisting variable:
498
+
يمكنك جعل هذا المكون نقي عن طريق تمرير الخاصية بدلا عن تعديل متغير موجود بالفعل:
499
499
500
500
<Sandpack>
501
501
@@ -519,12 +519,12 @@ export default function TeaSet() {
519
519
520
520
<LearnMorepath="/learn/keeping-components-pure">
521
521
522
-
Read**[Keeping Components Pure](/learn/keeping-components-pure)**to learn how to write components as pure, predictable functions.
522
+
اقرأ**[الحفاظ على المكونات نقية](/learn/keeping-components-pure)**لتتعلم كيفية كتابة مكونات نقية ودوال متنبئة.
523
523
524
524
</LearnMore>
525
525
526
-
## What's next? {/*whats-next*/}
526
+
## ماذا بعد ذلك؟ {/*whats-next*/}
527
527
528
-
Head over to [Your First Component](/learn/your-first-component)to start reading this chapter page by page!
528
+
توجه إلى [المكون الأول الخاص بك](/learn/your-first-component)لبدء قراءة هذا الفصل صفحة بصفحة!
529
529
530
-
Or, if you're already familiar with these topics, why not read about [Adding Interactivity](/learn/adding-interactivity)?
530
+
أو، إذا كنت بالفعل على دراية بهذه المواضيع، لماذا لا تقرأ عن [إضافة التفاعلية (Interactivity)](/learn/adding-interactivity)?
0 commit comments