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
Copy file name to clipboardExpand all lines: src/content/learn/sharing-state-between-components.md
+14-14
Original file line number
Diff line number
Diff line change
@@ -96,36 +96,36 @@ h3, p { margin: 5px 0px; }
96
96
Щоб скоординувати ці дві панелі, вам потрібно "підняти їхній стан вгору" до батьківського компонента в три кроки:
97
97
98
98
1.**Видалити** стан із дочірніх компонент.
99
-
2.**Передати**незмінні дані від спільного батька.
99
+
2.**Передати**жорсткокодовані дані від спільного батька.
100
100
3.**Додати** стан до спільного батька і передати його вниз разом з обробниками подій.
101
101
102
102
Це дозволить компоненту `Accordion`скоординувати обидві `Panel` і розгортати тільки одну на раз.
103
103
104
-
### Step 1: Remove state from the child components {/*step-1-remove-state-from-the-child-components*/}
104
+
### Крок 1: Видаліть стан з дочірніх компонент {/*step-1-remove-state-from-the-child-components*/}
105
105
106
-
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:
106
+
Ви передасьте контроль `isActive` до `Panel` батьківського компонента. Це означає що батьківський компоненнт передасть `isActive`до`Panel`як проп. Почніть з**видалення цього рядка**з `Panel`компонента:
107
107
108
108
```js
109
109
const [isActive, setIsActive] =useState(false);
110
110
```
111
111
112
-
And instead, add `isActive`to the `Panel`'s list of props:
112
+
Натомість додайте `isActive`до списку пропсів `Panel`:
113
113
114
114
```js
115
115
functionPanel({ title, children, isActive }) {
116
116
```
117
117
118
-
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!
118
+
Тепер батьківський компонента `Panel` може *контролювати* `isActive`, [передаючи його як проп.](/learn/passing-props-to-a-component) І навпаки, `Panel`компонент тепер *не має контролю* над значенням `isActive`-- тепер це залежить від батьківського компонента!
119
119
120
-
### Step 2: Pass hardcoded data from the common parent {/*step-2-pass-hardcoded-data-from-the-common-parent*/}
120
+
### Крок 2: Передайте жорсткокодовані дані з батьківського компонента {/*step-2-pass-hardcoded-data-from-the-common-parent*/}
121
121
122
-
To lift state up, you must locate the closest common parent component of *both* of the child components that you want to coordinate:
122
+
Щоб підняти стан вгору, ви повинні виявити найближчий спільний батьківський компонент *обох* дочірніх компонентів, які ви хочете скоординувати:
123
123
124
-
* `Accordion` *(closest common parent)*
124
+
* `Accordion` *(найближчий спільний батько)*
125
125
- `Panel`
126
126
- `Panel`
127
127
128
-
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:
128
+
У цьому прикладі, компонент `Accordion`. Оскільки він знаходиться над обогома панелями і може контролювати їхні пропси, це стане "джерелом правди" для визначення, яка панель є відкритою на даний момент. Зробіть так щоб компонент `Accordion`передавав жорсткокодоване значення `isActive` (наприклад, `true`) до обидвох панелей:
129
129
130
130
<Sandpack>
131
131
@@ -135,12 +135,12 @@ import { useState } from 'react';
135
135
exportdefaultfunctionAccordion() {
136
136
return (
137
137
<>
138
-
<h2>Almaty, Kazakhstan</h2>
138
+
<h2>Алмати, Казахстан</h2>
139
139
<Panel title="About" isActive={true}>
140
-
With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
140
+
Із населенням близько 2 мільйонів, Алмати є найбільшим містом в Казахстані. З1929по1997, воно було його столицею.
141
141
</Panel>
142
142
<Panel title="Etymology" isActive={true}>
143
-
The name comes from <span lang="kk-KZ">алма</span>, 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 <i lang="la">Malus sieversii</i> is considered a likely candidate for the ancestor of the modern domestic apple.
143
+
Назва походить від казахського слова <span lang="kk-KZ">алма</span>, що означає "яблуко" і часто перекладалось як "повний яблук". Насправді, регіон що оточує Алмати вважається прабатьківщиною яблука, і дика <i lang="la">Malus sieversii</i>вважається ймовірним кандидатом на предка сучасного домашнього яблука.
0 commit comments