Skip to content

Commit 09a3d46

Browse files
committed
feat: translate, part 3
1 parent 2a6ed3e commit 09a3d46

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/content/learn/sharing-state-between-components.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,36 @@ h3, p { margin: 5px 0px; }
9696
Щоб скоординувати ці дві панелі, вам потрібно "підняти їхній стан вгору" до батьківського компонента в три кроки:
9797

9898
1. **Видалити** стан із дочірніх компонент.
99-
2. **Передати** незмінні дані від спільного батька.
99+
2. **Передати** жорсткокодовані дані від спільного батька.
100100
3. **Додати** стан до спільного батька і передати його вниз разом з обробниками подій.
101101

102102
Це дозволить компоненту `Accordion`скоординувати обидві `Panel` і розгортати тільки одну на раз.
103103

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*/}
105105

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` компонента:
107107

108108
```js
109109
const [isActive, setIsActive] = useState(false);
110110
```
111111

112-
And instead, add `isActive` to the `Panel`'s list of props:
112+
Натомість додайте `isActive` до списку пропсів `Panel`:
113113

114114
```js
115115
function Panel({ title, children, isActive }) {
116116
```
117117
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`-- тепер це залежить від батьківського компонента!
119119
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*/}
121121
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+
Щоб підняти стан вгору, ви повинні виявити найближчий спільний батьківський компонент *обох* дочірніх компонентів, які ви хочете скоординувати:
123123
124-
* `Accordion` *(closest common parent)*
124+
* `Accordion` *(найближчий спільний батько)*
125125
- `Panel`
126126
- `Panel`
127127
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`) до обидвох панелей:
129129
130130
<Sandpack>
131131
@@ -135,12 +135,12 @@ import { useState } from 'react';
135135
export default function Accordion() {
136136
return (
137137
<>
138-
<h2>Almaty, Kazakhstan</h2>
138+
<h2>Алмати, Казахстан</h2>
139139
<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, воно було його столицею.
141141
</Panel>
142142
<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> вважається ймовірним кандидатом на предка сучасного домашнього яблука.
144144
</Panel>
145145
</>
146146
);
@@ -154,7 +154,7 @@ function Panel({ title, children, isActive }) {
154154
<p>{children}</p>
155155
) : (
156156
<button onClick={() => setIsActive(true)}>
157-
Show
157+
Показати
158158
</button>
159159
)}
160160
</section>
@@ -172,7 +172,7 @@ h3, p { margin: 5px 0px; }
172172
173173
</Sandpack>
174174
175-
Try editing the hardcoded `isActive` values in the `Accordion` component and see the result on the screen.
175+
Спробуйте відредагувати жорсткокодовані значення `isActive` у компоненті `Accordion` і подивіться на результат на екрані.
176176
177177
### Step 3: Add state to the common parent {/*step-3-add-state-to-the-common-parent*/}
178178

0 commit comments

Comments
 (0)