Skip to content

Commit 9f2569f

Browse files
committed
Translating managing state section
- Overview - Reacting to input with state - Choosing the state structure - sidebarLearn translation
1 parent 3416e30 commit 9f2569f

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

src/content/learn/managing-state.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
---
2-
title: Managing State
2+
title: إدارة الحالة
33
---
44

55
<Intro>
66

7-
As your application grows, it helps to be more intentional about how your state is organized and how the data flows between your components. Redundant or duplicate state is a common source of bugs. In this chapter, you'll learn how to structure your state well, how to keep your state update logic maintainable, and how to share state between distant components.
7+
مع نمو تطبيقك، من المفيد كونك أكثر حرصا بشأن أن تكون حالتك منظمة وأن تكون البيانات متدفقة خلال مكوناتك. تكرار أو نسخ الحالة هو مصدر شائع للأخطاء. في هذا الفصل، سوف تتعلم كيفية تهيئة حالتك جيدا، كيفية الحفاظ على منطق تحديث حالتك مصانا، وكيفية مشاركة الحالة بين المكونات المتباعدة.
88

99
</Intro>
1010

1111
<YouWillLearn isChapter={true}>
1212

13-
* [How to think about UI changes as state changes](/learn/reacting-to-input-with-state)
14-
* [How to structure state well](/learn/choosing-the-state-structure)
15-
* [How to "lift state up" to share it between components](/learn/sharing-state-between-components)
16-
* [How to control whether the state gets preserved or reset](/learn/preserving-and-resetting-state)
17-
* [How to consolidate complex state logic in a function](/learn/extracting-state-logic-into-a-reducer)
18-
* [How to pass information without "prop drilling"](/learn/passing-data-deeply-with-context)
19-
* [How to scale state management as your app grows](/learn/scaling-up-with-reducer-and-context)
13+
* [كيفية التفكير في تغييرات واجهة المستخدم كتغيرات في الحالة](/learn/reacting-to-input-with-state)
14+
* [كيفية هيكلة الحالة جيدا](/learn/choosing-the-state-structure)
15+
* [كيفية "رفع الحالة لمستوى أعلى" لمشاكارتها بين المكونات](/learn/sharing-state-between-components)
16+
* [كيفية التحكم في ما إذا تم حفظ الحالة أم إعادة تعيينها](/learn/preserving-and-resetting-state)
17+
* [كيفية ترسيخ منطق حالة معقد داخل دالة](/learn/extracting-state-logic-into-a-reducer)
18+
* [كيفية تمرير معلومات بدون "تسرب الخصائص"](/learn/passing-data-deeply-with-context)
19+
* [كيفية توسيع إدارة الحالة مع نمو تطبيقك](/learn/scaling-up-with-reducer-and-context)
2020

2121
</YouWillLearn>
2222

23-
## Reacting to input with state {/*reacting-to-input-with-state*/}
23+
## الاستجابة للمدخلات باستخدام الحالة {/*reacting-to-input-with-state*/}
2424

25-
With React, you won't modify the UI from code directly. For example, you won't write commands like "disable the button", "enable the button", "show the success message", etc. Instead, you will describe the UI you want to see for the different visual states of your component ("initial state", "typing state", "success state"), and then trigger the state changes in response to user input. This is similar to how designers think about UI.
25+
باستخدام React، لن تستطيع تعديل واجهة المستخدم عن طريق الكود مباشرة. على سبيل المثال، لن تكتب أوامر مثل "عطل الزر"، "فعل الزر"، إلخ. بدلا عن ذلك، سوف تصف واجهة المستخدم التي تريد أن ترها للحالات المرئية من مكوناتك ("حالة ابتدائية"، "حالة كتابية"، "حالة ناجحة")، ومن بعدها تنشيط تغيرات الحالة بناءا على مدخل المستخدم. هذا مشابه لتصور المصممين عن واجهة المستخدم.
26+
27+
هنا نموذج اختبار صمم باستخدام React. لاحظ كيف يستخدم متغير الحالة `status` لكي يحدد ما إذا سيفعل أم سيعطل زر الإرسال، وما إذا ستظهر رسالة نجاح بدلا عن ذلك.
2628

27-
Here is a quiz form built using React. Note how it uses the `status` state variable to determine whether to enable or disable the submit button, and whether to show the success message instead.
2829

2930
<Sandpack>
3031

@@ -37,7 +38,7 @@ export default function Form() {
3738
const [status, setStatus] = useState('typing');
3839

3940
if (status === 'success') {
40-
return <h1>That's right!</h1>
41+
return <h1>هذا صحيح!</h1>
4142
}
4243

4344
async function handleSubmit(e) {
@@ -58,9 +59,9 @@ export default function Form() {
5859

5960
return (
6061
<>
61-
<h2>City quiz</h2>
62+
<h2>اختبار المدينة</h2>
6263
<p>
63-
In which city is there a billboard that turns air into drinkable water?
64+
في أي مدينة يوجد لوحة إعلانية تقوم بتحويل الهواء إلى مياه صالحة للشرب؟
6465
</p>
6566
<form onSubmit={handleSubmit}>
6667
<textarea
@@ -73,7 +74,7 @@ export default function Form() {
7374
answer.length === 0 ||
7475
status === 'submitting'
7576
}>
76-
Submit
77+
أرسل
7778
</button>
7879
{error !== null &&
7980
<p className="Error">
@@ -86,12 +87,12 @@ export default function Form() {
8687
}
8788

8889
function submitForm(answer) {
89-
// Pretend it's hitting the network.
90+
// محاكاة للتواصل باستخدام الشبكة
9091
return new Promise((resolve, reject) => {
9192
setTimeout(() => {
92-
let shouldError = answer.toLowerCase() !== 'lima'
93+
let shouldError = answer.toLowerCase() !== 'lima'
9394
if (shouldError) {
94-
reject(new Error('Good guess but a wrong answer. Try again!'));
95+
reject(new Error('توقع جيد ولكن إجابة خاطئة. حاول مرة أخرى!'));
9596
} else {
9697
resolve();
9798
}
@@ -108,15 +109,15 @@ function submitForm(answer) {
108109

109110
<LearnMore path="/learn/reacting-to-input-with-state">
110111

111-
Read **[Reacting to Input with State](/learn/reacting-to-input-with-state)** to learn how to approach interactions with a state-driven mindset.
112+
اقرأ **[الاستجابة للمدخلات باستخدام الحالة](/learn/reacting-to-input-with-state)** لكي تتعلم كيفية الوصول لتعاملات مع عقلية معتمدة على الحالة.
112113

113114
</LearnMore>
114115

115-
## Choosing the state structure {/*choosing-the-state-structure*/}
116+
## اختيار هيكل الحالة {/*choosing-the-state-structure*/}
116117

117-
Structuring state well can make a difference between a component that is pleasant to modify and debug, and one that is a constant source of bugs. The most important principle is that state shouldn't contain redundant or duplicated information. If there's unnecessary state, it's easy to forget to update it, and introduce bugs!
118+
هيكلة الحالة جيدا يستطيع أن يصنع فارقا بين مكوّن قابل للإصلاح والتصحيح، وآخر يمثل مصدرا ثابتا للأخطاء. القاعدة الأكثر أهمية هي أنه لا يجب للحالة أن تحتوي على بيانات مكررة أو منسوخة. لو وجدت حالة غير ضرورية، فمن السهل نسيان تحديثها، وحدوث الأخطاء.
118119

119-
For example, this form has a **redundant** `fullName` state variable:
120+
على سبيل المثال، هذا نموذج يتضمن متغير الحالة `fullName` **مكرر**:
120121

121122
<Sandpack>
122123

@@ -140,23 +141,23 @@ export default function Form() {
140141

141142
return (
142143
<>
143-
<h2>Let’s check you in</h2>
144+
<h2>دعنا نقم بتسجيلك</h2>
144145
<label>
145-
First name:{' '}
146+
الاسم الأول:{' '}
146147
<input
147148
value={firstName}
148149
onChange={handleFirstNameChange}
149150
/>
150151
</label>
151152
<label>
152-
Last name:{' '}
153+
اسم العائلة:{' '}
153154
<input
154155
value={lastName}
155156
onChange={handleLastNameChange}
156157
/>
157158
</label>
158159
<p>
159-
Your ticket will be issued to: <b>{fullName}</b>
160+
تذكرتك سوف تسلم ل: <b>{fullName}</b>
160161
</p>
161162
</>
162163
);
@@ -169,7 +170,7 @@ label { display: block; margin-bottom: 5px; }
169170

170171
</Sandpack>
171172

172-
You can remove it and simplify the code by calculating `fullName` while the component is rendering:
173+
يمكنك حذفه وتبسيط الكود عن طريق جمع `fullName` بينما يصيّر المكوّن:
173174

174175
<Sandpack>
175176

@@ -192,23 +193,23 @@ export default function Form() {
192193

193194
return (
194195
<>
195-
<h2>Let’s check you in</h2>
196+
<h2>دعنا نقم بتسجيلك</h2>
196197
<label>
197-
First name:{' '}
198+
الاسم الأول:{' '}
198199
<input
199200
value={firstName}
200201
onChange={handleFirstNameChange}
201202
/>
202203
</label>
203204
<label>
204-
Last name:{' '}
205+
اسم العائلة:{' '}
205206
<input
206207
value={lastName}
207208
onChange={handleLastNameChange}
208209
/>
209210
</label>
210211
<p>
211-
Your ticket will be issued to: <b>{fullName}</b>
212+
تذكرتك سوف تسلم ل: <b>{fullName}</b>
212213
</p>
213214
</>
214215
);
@@ -221,11 +222,11 @@ label { display: block; margin-bottom: 5px; }
221222

222223
</Sandpack>
223224

224-
This might seem like a small change, but many bugs in React apps are fixed this way.
225+
هذا قد يبدو كتغير بسيط، ولكن كثير من الأخطاء في تطبيقات React يتم إصلاحها بهذه الطريقة.
225226

226227
<LearnMore path="/learn/choosing-the-state-structure">
227228

228-
Read **[Choosing the State Structure](/learn/choosing-the-state-structure)** to learn how to design the state shape to avoid bugs.
229+
اقرأ **[اختيار هيكل الحالة](/learn/choosing-the-state-structure)** لتتعلم كيفية تصميم بنية الحالة لتجنب الأخطاء.
229230

230231
</LearnMore>
231232

src/sidebarLearn.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@
121121
]
122122
},
123123
{
124-
"title": "Managing State",
124+
"title": "إدارة الحالة",
125125
"path": "/learn/managing-state",
126126
"tags": ["intermediate"],
127127
"routes": [
128128
{
129-
"title": "Reacting to Input with State",
129+
"title": "الاستجابة للمدخلات باستخدام الحالة",
130130
"path": "/learn/reacting-to-input-with-state"
131131
},
132132
{
133-
"title": "Choosing the State Structure",
133+
"title": "اختيار هيكل الحالة",
134134
"path": "/learn/choosing-the-state-structure"
135135
},
136136
{

0 commit comments

Comments
 (0)