diff --git a/src/content/learn/sharing-state-between-components.md b/src/content/learn/sharing-state-between-components.md
index 149164fe19..b3ee2c8854 100644
--- a/src/content/learn/sharing-state-between-components.md
+++ b/src/content/learn/sharing-state-between-components.md
@@ -1,31 +1,29 @@
---
-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.
+Иногда требуется, чтобы состояние двух компонентов всегда изменялось вместе. Для этого нужно удалить состояние из обоих компонентов, переместить его в ближайшего общего родителя и передать его им через пропсы. Это называется *подъемом состояния вверх* и является одним из наиболее распространенных приемов при написании кода на React.
-
-- How to share state between components by lifting it up
-- What are controlled and uncontrolled components
+- Как использовать одно состояние между компонентами, подняв его вверх
+- Что такое управляемые и неуправляемые компоненты
-## Lifting state up by example {/*lifting-state-up-by-example*/}
-
-In this example, a parent `Accordion` component renders two separate `Panel`s:
+## Подъём состояния на примере {/*lifting-state-up-by-example*/}
+В этом примере родительский компонент `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 +39,7 @@ function Panel({ title, children }) {
{children}
) : (
)}
@@ -51,12 +49,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 считается вероятным кандидатом на роль предка современного домашнего яблока.
>
);
@@ -73,59 +71,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` в значении `false`, поэтому они обе отображаются свернутыми
-
+
-Clicking either `Panel`'s button will only update that `Panel`'s `isActive` state alone
+Нажатие кнопки на одной из панелей приведет к обновлению состояния `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!
+Теперь родитель компонента `Panel` может *управлять* `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 +133,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 +152,7 @@ function Panel({ title, children, isActive }) {
{children}
) : (
)}
@@ -172,21 +170,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` нужно следить за тем *какая* панель активна в данный момент. Вместо булевого значения в состоянии можно хранить число, которое будет означать индекс активной панели:
```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):
+Нажатие на кнопку «Показать» в любой из панелей должно изменять индекс активной панели в `Accordion`. `Panel` не может напрямую установить состояние `activeIndex`, потому что оно определено внутри `Accordion`. Компоненту `Accordion` необходимо *явно разрешить* компоненту `Panel` изменять свое состояние, [передав обработчик события как проп](/learn/responding-to-events#passing-event-handlers-as-props):
```js
<>
@@ -205,7 +203,7 @@ Clicking the "Show" button in either `Panel` needs to change the active index in
>
```
-The `