Skip to content

Commit e153428

Browse files
committed
Added UA translation to useId page (1 part)
1 parent c471d38 commit e153428

File tree

8 files changed

+83
-25
lines changed

8 files changed

+83
-25
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/aws.xml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/uk.react.dev-fork.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/reference/react/useId.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ title: useId
66

77
`useId` is a React Hook for generating unique IDs that can be passed to accessibility attributes.
88

9+
`useId` — це хук для генерації унікальних ID, які можуть передаватись як атрибути доступності.
10+
911
```js
1012
const id = useId()
1113
```
@@ -20,7 +22,7 @@ const id = useId()
2022

2123
### `useId()` {/*useid*/}
2224

23-
Call `useId` at the top level of your component to generate a unique ID:
25+
Викличте `useId` на верхньому рівні вашого компонента, щоб згенерувати унікальне ID:
2426

2527
```js
2628
import { useId } from 'react';
@@ -30,37 +32,38 @@ function PasswordField() {
3032
// ...
3133
```
3234
33-
[See more examples below.](#usage)
35+
[Перегляньте більше прикладів нижче.](#usage)
3436
35-
#### Parameters {/*parameters*/}
37+
#### Параметри {/*parameters*/}
3638
37-
`useId` does not take any parameters.
39+
`useId` не приймає ніяких параметрів.
3840
39-
#### Returns {/*returns*/}
41+
#### Результат {/*returns*/}
4042
41-
`useId` returns a unique ID string associated with this particular `useId` call in this particular component.
43+
`useId` повертає унікальну ID стрінгу, пов'язану з конкретним запитом `useId` в цьому конкретньому компоненті.
4244
43-
#### Caveats {/*caveats*/}
45+
#### Застереження {/*caveats*/}
4446
45-
* `useId` is a Hook, so you can only call it **at the top level of your component** or your own Hooks. You can't call it inside loops or conditions. If you need that, extract a new component and move the state into it.
47+
* `useId` — це хук, тож він може бути викликаний тільки **на верхньому рівні вашого компонента** або у вашому власному Хуці. Ви не можете викликати його в циклах або умовах. Якщо ж є така потреба, то витягніть новий компонент та перемістіть в нього стан.
4648
47-
* `useId` **should not be used to generate keys** in a list. [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
49+
* `useId` **не повинно використовуватись для генерації ключів** у списках. [Ключі повинні генеруватись з ваших даних.](/learn/rendering-lists#where-to-get-your-key)
4850
49-
* `useId` currently cannot be used in [async Server Components](/reference/rsc/server-components#async-components-with-server-components).
51+
* `useId` на данний момент не може бути використано в [async Server Components](/reference/rsc/server-components#async-components-with-server-components).
5052
5153
---
5254
53-
## Usage {/*usage*/}
55+
## Використання {/*usage*/}
5456
5557
<Pitfall>
5658
57-
**Do not call `useId` to generate keys in a list.** [Keys should be generated from your data.](/learn/rendering-lists#where-to-get-your-key)
59+
**Не викликайте `useId` для генерації ключів у списку.** [Ключі повинні генеруватись з ваших даних.](/learn/rendering-lists#where-to-get-your-key)
60+
5861
5962
</Pitfall>
6063
61-
### Generating unique IDs for accessibility attributes {/*generating-unique-ids-for-accessibility-attributes*/}
64+
### Генеруйте унікальні ID для атрибутів доступності {/*generating-unique-ids-for-accessibility-attributes*/}
6265
63-
Call `useId` at the top level of your component to generate a unique ID:
66+
Викликайте `useId` на верхньому рівні вашої компоненти для генерації унікального ID:
6467
6568
```js [[1, 4, "passwordHintId"]]
6669
import { useId } from 'react';
@@ -70,7 +73,7 @@ function PasswordField() {
7073
// ...
7174
```
7275
73-
You can then pass the <CodeStep step={1}>generated ID</CodeStep> to different attributes:
76+
Далі ви можете передати <CodeStep step={1}>generated ID</CodeStep> до різних атрибутів:
7477
7578
```js [[1, 2, "passwordHintId"], [1, 3, "passwordHintId"]]
7679
<>
@@ -79,11 +82,11 @@ You can then pass the <CodeStep step={1}>generated ID</CodeStep> to different at
7982
</>
8083
```
8184
82-
**Let's walk through an example to see when this is useful.**
85+
**Давайте розглянемо приклади, коли це може бути корисно.**
8386
84-
[HTML accessibility attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) like [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) let you specify that two tags are related to each other. For example, you can specify that an element (like an input) is described by another element (like a paragraph).
87+
[Атрибути доступності HTML](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) такі як [`aria-describedby`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) дозволяють зазначити, що два теги пов'язані один з одним. Наприклад, ви можете визначити, що елемент (такий як input) описан іншим компонентом (такий як параграф).
8588
86-
In regular HTML, you would write it like this:
89+
В звичайному HTML, ви би написали наступне:
8790
8891
```html {5,8}
8992
<label>
@@ -98,7 +101,7 @@ In regular HTML, you would write it like this:
98101
</p>
99102
```
100103
101-
However, hardcoding IDs like this is not a good practice in React. A component may be rendered more than once on the page--but IDs have to be unique! Instead of hardcoding an ID, generate a unique ID with `useId`:
104+
Однак, такий хардкод ID не найкраща практика в React. Компонент може бути зарендерений на сторінці більш ніж один раз — але ID повинні бути унікальні! Замість того, щоб хардкодити ID, зренеруйте унікальне за допомогою `useId`:
102105
103106
```js {4,11,14}
104107
import { useId } from 'react';
@@ -115,14 +118,14 @@ function PasswordField() {
115118
/>
116119
</label>
117120
<p id={passwordHintId}>
118-
The password should contain at least 18 characters
121+
Пароль повинен буди довжиною не меньш ніж 18 символів
119122
</p>
120123
</>
121124
);
122125
}
123126
```
124127
125-
Now, even if `PasswordField` appears multiple times on the screen, the generated IDs won't clash.
128+
Тож, навіть якщо `PasswordField` з'явиться на сторінці багато разів, згенеровані ID не конфліктуватимуть.
126129
127130
<Sandpack>
128131
@@ -141,7 +144,7 @@ function PasswordField() {
141144
/>
142145
</label>
143146
<p id={passwordHintId}>
144-
The password should contain at least 18 characters
147+
Пароль повинен буди довжиною не меньш ніж 18 символів
145148
</p>
146149
</>
147150
);
@@ -150,9 +153,9 @@ function PasswordField() {
150153
export default function App() {
151154
return (
152155
<>
153-
<h2>Choose password</h2>
156+
<h2>Оберіть пароль</h2>
154157
<PasswordField />
155-
<h2>Confirm password</h2>
158+
<h2>Підтвердіть пароль</h2>
156159
<PasswordField />
157160
</>
158161
);
@@ -165,11 +168,12 @@ input { margin: 5px; }
165168
166169
</Sandpack>
167170
168-
[Watch this video](https://www.youtube.com/watch?v=0dNzNcuEuOo) to see the difference in the user experience with assistive technologies.
171+
[Перегляньте відео](https://www.youtube.com/watch?v=0dNzNcuEuOo), щоб побачити різницю користувацького досвіду з дороміжними технологіями.
169172
170173
<Pitfall>
171174
172175
With [server rendering](/reference/react-dom/server), **`useId` requires an identical component tree on the server and the client**. If the trees you render on the server and the client don't match exactly, the generated IDs won't match.
176+
Разом з [серверним рендерінгом](/reference/react-dom/server), **`useId` потребує ідентичного дерева компонент на сервері та на клієнті**. If the trees you render on the server and the client don't match exactly, the generated IDs won't match.
173177
174178
</Pitfall>
175179

0 commit comments

Comments
 (0)