`) has to line up. Otherwise, toggling `isActive` would recreate the whole tree below and [reset its state.](/learn/preserving-and-resetting-state) This is why, if a similar JSX tree gets returned in both cases, it is better to write them as a single piece of JSX.
+Имейте в виду, что если два разных блока JSX описывают одно и то же дерево, их вложенность (первый `
` → первый `
![]()
`) должна совпадать. В противном случае переключение `isActive` приведет к воссозданию всего дерева ниже и [сбросу его состояния.](/learn/preserving-and-resetting-state) Поэтому, если в обоих случаях возвращается похожее дерево JSX, лучше написать его как единый элемент JSX.
-#### Profile editor {/*profile-editor*/}
+#### Редактор профиля {/*profile-editor*/}
-Here is a small form implemented with plain JavaScript and DOM. Play with it to understand its behavior:
+Вот небольшая форма, реализованная с использованием обычного JavaScript и DOM. Поиграйте с ней, чтобы понять ее поведение:
@@ -801,11 +801,11 @@ label { display: block; margin-bottom: 20px; }
-This form switches between two modes: in the editing mode, you see the inputs, and in the viewing mode, you only see the result. The button label changes between "Edit" and "Save" depending on the mode you're in. When you change the inputs, the welcome message at the bottom updates in real time.
+Эта форма переключается между двумя режимами: в режиме редактирования вы видите поля ввода, а в режиме просмотра — только результат. Метка кнопки меняется между «Edit» и «Save» в зависимости от режима. При изменении полей ввода приветственное сообщение внизу обновляется в реальном времени.
-Your task is to reimplement it in React in the sandbox below. For your convenience, the markup was already converted to JSX, but you'll need to make it show and hide the inputs like the original does.
+Ваша задача — переписать ее в React в песочнице ниже. Для вашего удобства разметка уже преобразована в JSX, но вам нужно будет сделать так, чтобы поля ввода отображались и скрывались, как в оригинале.
-Make sure that it updates the text at the bottom, too!
+Убедитесь, что текст внизу также обновляется!
@@ -840,9 +840,9 @@ label { display: block; margin-bottom: 20px; }
-You will need two state variables to hold the input values: `firstName` and `lastName`. You're also going to need an `isEditing` state variable that holds whether to display the inputs or not. You should _not_ need a `fullName` variable because the full name can always be calculated from the `firstName` and the `lastName`.
+Вам понадобятся две переменные состояния для хранения значений полей ввода: `firstName` и `lastName`. Вам также понадобится переменная состояния `isEditing`, которая будет хранить информацию о том, отображать ли поля ввода или нет. Вам _не_ понадобится переменная `fullName`, поскольку полное имя всегда можно вычислить из `firstName` и `lastName`.
-Finally, you should use [conditional rendering](/learn/conditional-rendering) to show or hide the inputs depending on `isEditing`.
+Наконец, вы должны использовать [условный рендеринг](/learn/conditional-rendering) для отображения или скрытия полей ввода в зависимости от `isEditing`.
@@ -900,13 +900,13 @@ label { display: block; margin-bottom: 20px; }
-Compare this solution to the original imperative code. How are they different?
+Сравните это решение с исходным императивным кодом. Чем они отличаются?
-#### Refactor the imperative solution without React {/*refactor-the-imperative-solution-without-react*/}
+#### Рефакторинг императивного решения без React {/*refactor-the-imperative-solution-without-react*/}
-Here is the original sandbox from the previous challenge, written imperatively without React:
+Вот исходная песочница из предыдущего задания, написанная императивно без React:
@@ -1003,9 +1003,9 @@ label { display: block; margin-bottom: 20px; }
-Imagine React didn't exist. Can you refactor this code in a way that makes the logic less fragile and more similar to the React version? What would it look like if the state was explicit, like in React?
+Представьте, что React не существует. Можете ли вы переписать этот код таким образом, чтобы сделать логику менее хрупкой и более похожей на версию React? Как бы это выглядело, если бы состояние было явным, как в React?
-If you're struggling to think where to start, the stub below already has most of the structure in place. If you start here, fill in the missing logic in the `updateDOM` function. (Refer to the original code where needed.)
+Если вы испытываете трудности с тем, с чего начать, заглушка ниже уже содержит большую часть структуры. Если вы начнете отсюда, заполните недостающую логику в функции `updateDOM`. (При необходимости обратитесь к исходному коду.)
@@ -1112,7 +1112,7 @@ label { display: block; margin-bottom: 20px; }
-The missing logic included toggling the display of inputs and content, and updating the labels:
+Отсутствующая логика включала переключение отображения полей ввода и контента, а также обновление меток:
@@ -1229,7 +1229,7 @@ label { display: block; margin-bottom: 20px; }
-The `updateDOM` function you wrote shows what React does under the hood when you set the state. (However, React also avoids touching the DOM for properties that have not changed since the last time they were set.)
+Функция `updateDOM`, которую вы написали, показывает, что делает React под капотом при установке состояния. (Однако React также избегает взаимодействия с DOM для свойств, которые не изменились с момента их последнего установки.)