Skip to content

Commit a2e3bb8

Browse files
authored
Merge pull request #848 from XamzatJR/fragment-translation
Translation for Fragment.md
2 parents c007b23 + 7e43580 commit a2e3bb8

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/content/reference/react/Fragment.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: <Fragment> (<>...</>)
44

55
<Intro>
66

7-
`<Fragment>`, often used via `<>...</>` syntax, lets you group elements without a wrapper node.
7+
`<Fragment>`, или `<>...</>`, позволяет группировать элементы без тега-обертки.
88

99
```js
1010
<>
@@ -19,29 +19,29 @@ title: <Fragment> (<>...</>)
1919

2020
---
2121

22-
## Reference {/*reference*/}
22+
## Справочник {/*reference*/}
2323

2424
### `<Fragment>` {/*fragment*/}
2525

26-
Wrap elements in `<Fragment>` to group them together in situations where you need a single element. Grouping elements in `Fragment` has no effect on the resulting DOM; it is the same as if the elements were not grouped. The empty JSX tag `<></>` is shorthand for `<Fragment></Fragment>` in most cases.
26+
Оберните элементы в `<Fragment>` для объединения их, когда вам нужен один элемент. Группировка элементов в `Fragment` не влияет на итоговый DOM; оно остаётся таким же, как если бы элементы не были сгруппированы. Пустой JSX-тег `<></>` обычно является сокращением для `<Fragment></Fragment>`.
2727

28-
#### Props {/*props*/}
28+
#### Пропсы {/*props*/}
2929

30-
- **optional** `key`: Fragments declared with the explicit `<Fragment>` syntax may have [keys.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
30+
- **необязательный** `key`: Фрагменты, объявленные с помощью явного синтаксиса `<Fragment>`, могут иметь [ключи.](/learn/rendering-lists#keeping-list-items-in-order-with-key)
3131

32-
#### Caveats {/*caveats*/}
32+
#### Предостережения {/*caveats*/}
3333

34-
- If you want to pass `key` to a Fragment, you can't use the `<>...</>` syntax. You have to explicitly import `Fragment` from `'react'` and render `<Fragment key={yourKey}>...</Fragment>`.
34+
- Если вы хотите передать `key` фрагменту, то воспользоваться краткой формой `<>...</>` не выйдет. Вы должны явно импортировать `Fragment` из `'react'` и рендерить `<Fragment key={yourKey}>...</Fragment>`.
3535

36-
- React does not [reset state](/learn/preserving-and-resetting-state) when you go from rendering `<><Child /></>` to `[<Child />]` or back, or when you go from rendering `<><Child /></>` to `<Child />` and back. This only works a single level deep: for example, going from `<><><Child /></></>` to `<Child />` resets the state. See the precise semantics [here.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b)
36+
- React не [сбрасывает состояние](/learn/preserving-and-resetting-state) при переходе от рендеринга `<><Child /></>` к `[<Child />]` или обратно, или при переходе от `<><Child /></>` к `<Child />` или обратно. Это работает только на одном уровне вложенности: например, переход от `<><><Child /></></>` к `<Child />` сбрасывает состояние. Точную семантику можно посмотреть [здесь.](https://gist.github.com/clemmy/b3ef00f9507909429d8aa0d3ee4f986b)
3737

3838
---
3939

40-
## Usage {/*usage*/}
40+
## Применение {/*usage*/}
4141

42-
### Returning multiple elements {/*returning-multiple-elements*/}
42+
### Возвращение нескольких элементов {/*returning-multiple-elements*/}
4343

44-
Use `Fragment`, or the equivalent `<>...</>` syntax, to group multiple elements together. You can use it to put multiple elements in any place where a single element can go. For example, a component can only return one element, but by using a Fragment you can group multiple elements together and then return them as a group:
44+
Используйте `Fragment` или `<>...</>`, чтобы сгруппировать несколько элементов. Вы можете применить его для размещения нескольких элементов в любом месте, где может находиться один элемент. Например, компонент может возвращать только один элемент, но с помощью `Fragment` можно сгруппировать несколько элементов вместе и затем вернуть их:
4545

4646
```js {3,6}
4747
function Post() {
@@ -54,16 +54,16 @@ function Post() {
5454
}
5555
```
5656

57-
Fragments are useful because grouping elements with a Fragment has no effect on layout or styles, unlike if you wrapped the elements in another container like a DOM element. If you inspect this example with the browser tools, you'll see that all `<h1>` and `<article>` DOM nodes appear as siblings without wrappers around them:
57+
Фрагменты полезны тем, что группировка элементов с их помощью не влияет на макет или стили, в отличие от оборачивания элементов в другой контейнер, например, DOM-элемент. Изучив этот пример в браузере с помощью инструментов разработчика, вы увидите, что все DOM-узлы `<h1>` и `<article>` отображаются рядом и без обёрток:
5858

5959
<Sandpack>
6060

6161
```js
6262
export default function Blog() {
6363
return (
6464
<>
65-
<Post title="An update" body="It's been a while since I posted..." />
66-
<Post title="My new blog" body="I am starting a new blog!" />
65+
<Post title="Обновление" body="Давненько я не писал..." />
66+
<Post title="Мой новый блог" body="Я начинаю новый блог!" />
6767
</>
6868
)
6969
}
@@ -94,9 +94,9 @@ function PostBody({ body }) {
9494

9595
<DeepDive>
9696

97-
#### How to write a Fragment without the special syntax? {/*how-to-write-a-fragment-without-the-special-syntax*/}
97+
#### Как написать фрагмент без специального синтаксиса? {/*how-to-write-a-fragment-without-the-special-syntax*/}
9898

99-
The example above is equivalent to importing `Fragment` from React:
99+
Приведенный выше пример эквивалентен импорту `Fragment` из React:
100100

101101
```js {1,5,8}
102102
import { Fragment } from 'react';
@@ -111,15 +111,15 @@ function Post() {
111111
}
112112
```
113113

114-
Usually you won't need this unless you need to [pass a `key` to your `Fragment`.](#rendering-a-list-of-fragments)
114+
В большинстве случаев это не нужно, за исключением ситуаций, когда необходимо [передать фрагменту `key`.](#rendering-a-list-of-fragments)
115115

116116
</DeepDive>
117117

118118
---
119119

120-
### Assigning multiple elements to a variable {/*assigning-multiple-elements-to-a-variable*/}
120+
### Присвоение переменной нескольких элементов {/*assigning-multiple-elements-to-a-variable*/}
121121

122-
Like any other element, you can assign Fragment elements to variables, pass them as props, and so on:
122+
Как и любой другой элемент, вы можете присваивать элементы `Fragment` переменным, передавать их в качестве пропсов и так далее:
123123

124124
```js
125125
function CloseDialog() {
@@ -131,25 +131,25 @@ function CloseDialog() {
131131
);
132132
return (
133133
<AlertDialog buttons={buttons}>
134-
Are you sure you want to leave this page?
134+
Вы уверены, что хотите покинуть эту страницу?
135135
</AlertDialog>
136136
);
137137
}
138138
```
139139
140140
---
141141
142-
### Grouping elements with text {/*grouping-elements-with-text*/}
142+
### Группировка элементов с текстом {/*grouping-elements-with-text*/}
143143
144-
You can use `Fragment` to group text together with components:
144+
Вы можете использовать `Fragment` для группировки текста вместе с компонентами:
145145
146146
```js
147147
function DateRangePicker({ start, end }) {
148148
return (
149149
<>
150-
From
150+
С
151151
<DatePicker date={start} />
152-
to
152+
до
153153
<DatePicker date={end} />
154154
</>
155155
);
@@ -158,9 +158,9 @@ function DateRangePicker({ start, end }) {
158158
159159
---
160160
161-
### Rendering a list of Fragments {/*rendering-a-list-of-fragments*/}
161+
### Рендеринг списка фрагментов {/*rendering-a-list-of-fragments*/}
162162
163-
Here's a situation where you need to write `Fragment` explicitly instead of using the `<></>` syntax. When you [render multiple elements in a loop](/learn/rendering-lists), you need to assign a `key` to each element. If the elements within the loop are Fragments, you need to use the normal JSX element syntax in order to provide the `key` attribute:
163+
Рассмотрим ситуацию, где вы должны использовать `Fragment`, а не его краткую форму `<></>`. Когда вы [рендерите несколько элементов в цикле](/learn/rendering-lists), то каждому из них нужно присвоить `key`. Если элементы цикла являются фрагментами, то вам необходимо использовать стандартный синтаксис JSX-элементов, чтобы это сделать:
164164
165165
```js {3,6}
166166
function Blog() {
@@ -173,16 +173,16 @@ function Blog() {
173173
}
174174
```
175175
176-
You can inspect the DOM to verify that there are no wrapper elements around the Fragment children:
176+
Вы можете проверить DOM и убедиться, что дочерние элементы фрагмента ни во что не обернуты:
177177
178178
<Sandpack>
179179
180180
```js
181181
import { Fragment } from 'react';
182182

183183
const posts = [
184-
{ id: 1, title: 'An update', body: "It's been a while since I posted..." },
185-
{ id: 2, title: 'My new blog', body: 'I am starting a new blog!' }
184+
{ id: 1, title: 'Обновление', body: "Давненько я не писал..." },
185+
{ id: 2, title: 'Мой новый блог', body: 'Я начинаю новый блог!' }
186186
];
187187

188188
export default function Blog() {

0 commit comments

Comments
 (0)