diff --git a/src/content/learn/sharing-state-between-components.md b/src/content/learn/sharing-state-between-components.md
index 2fbef8918..2c1eafd09 100644
--- a/src/content/learn/sharing-state-between-components.md
+++ b/src/content/learn/sharing-state-between-components.md
@@ -1,31 +1,31 @@
---
-title: Sharing State Between Components
+title: مشاركة الحالة بين المكونات
---
-Sometimes, you want the state of two components to always change together. To do it, remove state from both of them, move it to their closest common parent, and then pass it down to them via props. This is known as *lifting state up,* and it's one of the most common things you will do writing React code.
+أحيانًا، تريد أن تتغير حالة مكوّنين دائمًا معًا. لتحقيق ذلك، أزِل الحالة من كليهما، وانقلها إلى أقرب مكوّن أب مشترك لهما، ثم مرّرها إليهما عبر الخصائص (props). يُعرف هذا بـ *رفع الحالة لمستوى أعلى (lifting state up)*، وهو من أكثر الأمور شيوعًا التي ستفعلها عند كتابة كود React.
-- How to share state between components by lifting it up
-- What are controlled and uncontrolled components
+- كيفية مشاركة الحالة بين المكونات عن طريق رفعها لأعلى
+- ما المقصود بالمكوّنات المُتحكَّم فيها (controlled) وغير المُتحكَّم فيها (uncontrolled)
-## Lifting state up by example {/*lifting-state-up-by-example*/}
+## رفع الحالة لمستوى أعلى: مثال {/*lifting-state-up-by-example*/}
-In this example, a parent `Accordion` component renders two separate `Panel`s:
+في هذا المثال، يعرض المكوّن الأب `Accordion` لوحتين منفصلتين `Panel`:
* `Accordion`
- `Panel`
- `Panel`
-Each `Panel` component has a boolean `isActive` state that determines whether its content is visible.
+لكل مكوّن `Panel` حالة منطقية `isActive` تحدد ما إذا كان محتواه ظاهرًا.
-Press the Show button for both panels:
+اضغط على زر "إظهار" في اللوحتين:
@@ -41,7 +41,7 @@ function Panel({ title, children }) {
{children}
) : (
)}
@@ -51,12 +51,12 @@ function Panel({ title, children }) {
export default function Accordion() {
return (
<>
-
Almaty, Kazakhstan
-
- With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
+
ألماتي، كازاخستان
+
+ يبلغ عدد سكانها نحو 2 مليون نسمة، وهي أكبر مدن كازاخستان. وكانت عاصمة البلاد من عام 1929 حتى عام 1997.
-
- The name comes from алма, the Kazakh word for "apple" and is often translated as "full of apples". In fact, the region surrounding Almaty is thought to be the ancestral home of the apple, and the wild Malus sieversii is considered a likely candidate for the ancestor of the modern domestic apple.
+
+ الاسم مأخوذ من алма، وهي كلمة كازاخية تعني "تفاحة"، وكثيرًا ما تُترجم بمعنى "مليئة بالتفاح". والمنطقة المحيطة بألماتي يُعتقد أنها الموطن الأصلي للتفاح، ويُعدّ النوع البري Malus sieversii من أرجح أسلاف التفاح المنزلي الحديث.
>
);
@@ -64,6 +64,7 @@ export default function Accordion() {
```
```css
+body { direction: rtl; }
h3, p { margin: 5px 0px; }
.panel {
padding: 10px;
@@ -73,59 +74,59 @@ h3, p { margin: 5px 0px; }
-Notice how pressing one panel's button does not affect the other panel--they are independent.
+لاحظ أن الضغط على زر لوحة لا يؤثر على اللوحة الأخرى، فهما مستقلتان.
-
+
-Initially, each `Panel`'s `isActive` state is `false`, so they both appear collapsed
+في البداية، حالة `isActive` لكل `Panel` تساوي `false`، لذا تظهر كلتاهما مطوية
-
+
-Clicking either `Panel`'s button will only update that `Panel`'s `isActive` state alone
+النقر على زر أي `Panel` يحدّث حالة `isActive` الخاصة به فقط
-**But now let's say you want to change it so that only one panel is expanded at any given time.** With that design, expanding the second panel should collapse the first one. How would you do that?
+**لكن لنفترض الآن أنك تريد تغيير السلوك بحيث تكون لوحة واحدة فقط مفتوحة في أي وقت.** مع هذا التصميم، فتح اللوحة الثانية يجب أن يطوي الأولى. كيف يمكنك فعل ذلك؟
-To coordinate these two panels, you need to "lift their state up" to a parent component in three steps:
+لتنسيق عمل هاتين اللوحتين، تحتاج إلى "رفع حالتهما لمستوى أعلى" إلى مكوّن أب في ثلاث خطوات:
-1. **Remove** state from the child components.
-2. **Pass** hardcoded data from the common parent.
-3. **Add** state to the common parent and pass it down together with the event handlers.
+1. **أزِل** الحالة من المكوّنات الابنة.
+2. **مرّر** بيانات ثابتة من المكوّن الأب المشترك.
+3. **أضِف** الحالة إلى المكوّن الأب المشترك، ومرّرها لأسفل مع معالجات الأحداث.
-This will allow the `Accordion` component to coordinate both `Panel`s and only expand one at a time.
+هذا سيمكّن المكوّن `Accordion` من تنسيق عمل اللوحتين، وتوسيع لوحة واحدة فقط في كل مرة.
-### Step 1: Remove state from the child components {/*step-1-remove-state-from-the-child-components*/}
+### الخطوة 1: إزالة الحالة من المكوّنات الابنة {/*step-1-remove-state-from-the-child-components*/}
-You will give control of the `Panel`'s `isActive` to its parent component. This means that the parent component will pass `isActive` to `Panel` as a prop instead. Start by **removing this line** from the `Panel` component:
+ستمنح التحكم في `isActive` الخاص بـ `Panel` إلى مكوّنه الأب. وهذا يعني أن المكوّن الأب سيمرر `isActive` إلى `Panel` كخاصية بدلًا من ذلك. ابدأ بـ **حذف هذا السطر** من المكوّن `Panel`:
```js
const [isActive, setIsActive] = useState(false);
```
-And instead, add `isActive` to the `Panel`'s list of props:
+وبدلًا من ذلك، أضِف `isActive` إلى قائمة الخصائص الخاصة بـ `Panel`:
```js
function Panel({ title, children, isActive }) {
```
-Now the `Panel`'s parent component can *control* `isActive` by [passing it down as a prop.](/learn/passing-props-to-a-component) Conversely, the `Panel` component now has *no control* over the value of `isActive`--it's now up to the parent component!
+الآن يمكن للمكوّن الأب أن *يتحكم* في `isActive` عن طريق [تمريره كخاصية.](/learn/passing-props-to-a-component) في المقابل، لم يعد للمكوّن `Panel` *أي تحكم* في قيمة `isActive`، فالأمر أصبح بيد المكوّن الأب!
-### Step 2: Pass hardcoded data from the common parent {/*step-2-pass-hardcoded-data-from-the-common-parent*/}
+### الخطوة 2: تمرير بيانات ثابتة من المكوّن الأب المشترك {/*step-2-pass-hardcoded-data-from-the-common-parent*/}
-To lift state up, you must locate the closest common parent component of *both* of the child components that you want to coordinate:
+لرفع الحالة لمستوى أعلى، يجب أن تحدد أقرب مكوّن أب مشترك لـ *كلا* المكوّنين الابنين اللذين تريد تنسيق عملهما:
-* `Accordion` *(closest common parent)*
+* `Accordion` *(أقرب مكوّن أب مشترك)*
- `Panel`
- `Panel`
-In this example, it's the `Accordion` component. Since it's above both panels and can control their props, it will become the "source of truth" for which panel is currently active. Make the `Accordion` component pass a hardcoded value of `isActive` (for example, `true`) to both panels:
+في هذا المثال، هذا المكوّن هو `Accordion`. بما أنه أعلى من اللوحتين ويستطيع التحكم في خصائصهما، فسيصبح "مصدر الحقيقة" لتحديد اللوحة النشطة حاليًا. اجعل المكوّن `Accordion` يمرر قيمة ثابتة لـ `isActive` (مثلًا `true`) إلى اللوحتين:
@@ -135,12 +136,12 @@ import { useState } from 'react';
export default function Accordion() {
return (
<>
-
Almaty, Kazakhstan
-
- With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
+
ألماتي، كازاخستان
+
+ يبلغ عدد سكانها نحو 2 مليون نسمة، وهي أكبر مدن كازاخستان. وكانت عاصمة البلاد من عام 1929 حتى عام 1997.
-
- The name comes from алма, the Kazakh word for "apple" and is often translated as "full of apples". In fact, the region surrounding Almaty is thought to be the ancestral home of the apple, and the wild Malus sieversii is considered a likely candidate for the ancestor of the modern domestic apple.
+
+ الاسم مأخوذ من алма، وهي كلمة كازاخية تعني "تفاحة"، وكثيرًا ما تُترجم بمعنى "مليئة بالتفاح". والمنطقة المحيطة بألماتي يُعتقد أنها الموطن الأصلي للتفاح، ويُعدّ النوع البري Malus sieversii من أرجح أسلاف التفاح المنزلي الحديث.
>
);
@@ -154,7 +155,7 @@ function Panel({ title, children, isActive }) {
{children}
) : (
)}
@@ -163,6 +164,7 @@ function Panel({ title, children, isActive }) {
```
```css
+body { direction: rtl; }
h3, p { margin: 5px 0px; }
.panel {
padding: 10px;
@@ -172,21 +174,21 @@ h3, p { margin: 5px 0px; }
-Try editing the hardcoded `isActive` values in the `Accordion` component and see the result on the screen.
+جرّب تعديل القيم الثابتة لـ `isActive` في المكوّن `Accordion`، ولاحظ النتيجة على الشاشة.
-### Step 3: Add state to the common parent {/*step-3-add-state-to-the-common-parent*/}
+### الخطوة 3: إضافة الحالة إلى المكوّن الأب المشترك {/*step-3-add-state-to-the-common-parent*/}
-Lifting state up often changes the nature of what you're storing as state.
+غالبًا ما يغيّر رفع الحالة لمستوى أعلى طبيعة ما تخزنه كحالة.
-In this case, only one panel should be active at a time. This means that the `Accordion` common parent component needs to keep track of *which* panel is the active one. Instead of a `boolean` value, it could use a number as the index of the active `Panel` for the state variable:
+في هذه الحالة، ينبغي أن تكون لوحة واحدة فقط نشطة في كل مرة. وهذا يعني أن المكوّن الأب المشترك `Accordion` يحتاج إلى تتبّع *أي* لوحة هي النشطة. وبدلًا من قيمة منطقية (`boolean`)، يمكنه استخدام رقم كفهرس (index) للوحة النشطة في متغير الحالة:
```js
const [activeIndex, setActiveIndex] = useState(0);
```
-When the `activeIndex` is `0`, the first panel is active, and when it's `1`, it's the second one.
+عندما تكون `activeIndex` تساوي `0`، تكون اللوحة الأولى نشطة، وعندما تساوي `1`، تكون اللوحة الثانية نشطة.
-Clicking the "Show" button in either `Panel` needs to change the active index in `Accordion`. A `Panel` can't set the `activeIndex` state directly because it's defined inside the `Accordion`. The `Accordion` component needs to *explicitly allow* the `Panel` component to change its state by [passing an event handler down as a prop](/learn/responding-to-events#passing-event-handlers-as-props):
+النقر على زر "إظهار" في أي من مكوّنات `Panel` يجب أن يغيّر الفهرس النشط في `Accordion`. لا يستطيع `Panel` تعيين `activeIndex` مباشرة لأنها معرّفة داخل `Accordion`. لذلك يجب أن يسمح المكوّن `Accordion` *صراحةً* للمكوّن `Panel` بتغيير حالته، وذلك بـ [تمرير معالج حدث كخاصية](/learn/responding-to-events#passing-event-handlers-as-props):
```js
<>
@@ -205,7 +207,7 @@ Clicking the "Show" button in either `Panel` needs to change the active index in
>
```
-The `