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
## مشاركة الحالة بين المكونات {/*sharing-state-between-components*/}
234
234
235
-
أحيانا، أنت تريد الحالة ذات المكونين أن تتغير دائما مع بعضها البعض. لعمل ذلك، احذف حالة من كليهما، انقلها لأقرب مكون أب، وبعد ذلك مررها لأسفل باستخدام الخصائص. هذا ما يعرف بـ "رفع الحالة لمستوى أعلى"، وهو واحد من أكثر الأشياء شيوعا التي ستسعملها أثناء كتابتك لكود React.
235
+
أحيانا، أنت تريد الحالة ذات المكونين أن تتغير دائما مع بعضها البعض. لعمل ذلك، احذف حالة من كليهما، انقلها لأقرب مكون أب، وبعد ذلك مررها لأسفل باستخدام الخصائص. هذا ما يعرف بـ "رفع الحالة لمستوى أعلى (lifting state up)"، وهو واحد من أكثر الأشياء شيوعا التي ستسعملها أثناء كتابتك لكود React.
236
236
237
237
في هذا المثال، في كل مرة يجب أن تكون قائمة واحدة فقط نشطة. لتحقيق ذلك، بدلا من حفظ الحالة النشطة داخل كل قائمة بمفردها، المكونّ الأب يحمل الحالة ويحدد الخصائص لمكوناته الأبناء.
238
238
@@ -501,9 +501,9 @@ textarea {
501
501
502
502
</LearnMore>
503
503
504
-
## Extracting state logic into a reducer {/*extracting-state-logic-into-a-reducer*/}
504
+
## استخلاص منطق الحالة إلى مخفض (reducer) {/*extracting-state-logic-into-a-reducer*/}
505
505
506
-
Components with many state updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the state update logic outside your component in a single function, called "reducer". Your event handlers become concise because they only specify the user "actions". At the bottom of the file, the reducer function specifies how the state should update in response to each action!
506
+
المكونات ذات تحديثات حالة كثيرة المنتشرة خلال كثير من معالجات الأحداث (event handlers) قد تصبح معقدة. لمثل هذه الأحوال، يمكنك تجميع جميع منطق تحديث الحالة خارج مكوّنك داخل دالة واحدة، تدعى "مخفض (reducer)". معالجات الأحداث خاصتك ستصبح موجزة لأنها تحدد "إجراءات (actions)" المستخدم فقط. في أسفل الملف، دالة المخفض تحدد كيف يجب أن تحدث الحالة إستجابة لكل إجراء!
Read**[Extracting State Logic into a Reducer](/learn/extracting-state-logic-into-a-reducer)**to learn how to consolidate logic in the reducer function.
697
+
اقرأ**[استخلاص منطق الحالة إلى مخفض (reducer)](/learn/extracting-state-logic-into-a-reducer)**لتتعلم كيفية تجميع منطق داخل دالة المخفض.
698
698
699
699
</LearnMore>
700
700
701
-
## Passing data deeply with context {/*passing-data-deeply-with-context*/}
701
+
## تمرير البيانات إلى عمق باستخدام السياق (context) {/*passing-data-deeply-with-context*/}
702
702
703
-
Usually, you will pass information from a parent component to a child component via props. But passing props can become inconvenient if you need to pass some prop through many components, or if many components need the same information. Context lets the parent component make some information available to any component in the tree below it—no matter how deep it is—without passing it explicitly through props.
703
+
عادة، سوف تقوم بتمرير معلومات من مكوّن أب إلى مكوّن ابن بواسطة الخصائص (props). لكن تمرير الخصائص قد يكون غير مجدٍ لو احتجت لتمرير بعض الخصائص خلال مكونات عديدة، أو لو أن العديد من المكونات تحتاج نفس المعلومات. السياق (context) يتيح للمكون الأب جعل بعض المعلومات متوفرة لأي مكون أدناه في الشجرة-لا يهم مقدار عمق المكون-بدون تمريرها مباشرة عن طريق الخصائص.
704
704
705
-
Here, the`Heading`component determines its heading level by "asking" the closest `Section`for its level. Each`Section`tracks its own level by asking the parent `Section`and adding one to it. Every`Section`provides information to all components below it without passing props--it does that through context.
705
+
هنا، المكوّن`Heading`يحدد مستوى عنوانه عن طريق "سؤال" أقرب `Section`لمستواها. كل`Section`يتتبع مستواه الخاص عن طريق سؤال `Section`الأب وإضافة واحد له. كل`Section`بتوفير معلومات لجميع المكونات أدناه دون نقل الخصائص--وهذا يتم عبر السياق (context).
Read**[Passing Data Deeply with Context](/learn/passing-data-deeply-with-context)**to learn about using context as an alternative to passing props.
799
+
اقرأ**[تمرير البيانات إلى عمق باستخدام السياق (context)](/learn/passing-data-deeply-with-context)**لتتعلم عن استخدام السياق (context) كبديل لتمرير الخصائص.
800
800
801
801
</LearnMore>
802
802
803
-
## Scaling up with reducer and context {/*scaling-up-with-reducer-and-context*/}
803
+
## التوسع بواسطة المخفض (reducer) و السياق (context) {/*scaling-up-with-reducer-and-context*/}
804
804
805
-
Reducers let you consolidate a component’s state update logic. Context lets you pass information deep down to other components. You can combine reducers and context together to manage state of a complex screen.
805
+
المخفضات (Reducers) تتيح لك تجميع منطق تحديث الحالة لمكون. السياق (Context) تتيح لك تمرير معلومات بعمق إلى أسفل لمكونات أخرى. يمكنك جمع المخفضات والسايق معا لتدير الحالة الخاصة بشاشة معقدة.
806
806
807
-
With this approach, a parent component with complex state manages it with a reducer. Other components anywhere deep in the tree can read its state via context. They can also dispatch actions to update that state.
807
+
مع هذا النهج، يدير المكون الأب حالة معقدة بواسطة مخفض. المكونات الأخرى في أي عمق كانت داخل الشجرة يمكن قراءة حالتها بواسطة السياق. يمكنهم أيضا إرسال الأوامر لتحديث الحالة.
0 commit comments