Skip to content

Commit 12d3002

Browse files
authored
Merge pull request #869 from YashinaAnastasia/transl
Translation for "lazy"
2 parents c882747 + 3981c45 commit 12d3002

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

src/content/reference/react/lazy.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ title: lazy
44

55
<Intro>
66

7-
`lazy` lets you defer loading component's code until it is rendered for the first time.
8-
7+
`lazy` позволяет отложить загрузку кода компонента до его первого рендеринга.
98
```js
109
const SomeComponent = lazy(load)
1110
```
@@ -16,63 +15,63 @@ const SomeComponent = lazy(load)
1615

1716
---
1817

19-
## Reference {/*reference*/}
18+
## Справочник {/*reference*/}
2019

2120
### `lazy(load)` {/*lazy*/}
2221

23-
Call `lazy` outside your components to declare a lazy-loaded React component:
22+
Вызовите `lazy` вне ваших компонентов, чтобы объявить компонент React с ленивой загрузкой:
2423

2524
```js
2625
import { lazy } from 'react';
2726

2827
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
2928
```
3029

31-
[See more examples below.](#usage)
30+
[См. другие примеры ниже.](#usage)
3231

33-
#### Parameters {/*parameters*/}
32+
#### Параметры {/*parameters*/}
3433

35-
* `load`: A function that returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or another *thenable* (a Promise-like object with a `then` method). React will not call `load` until the first time you attempt to render the returned component. After React first calls `load`, it will wait for it to resolve, and then render the resolved value as a React component. Both the returned Promise and the Promise's resolved value will be cached, so React will not call `load` more than once. If the Promise rejects, React will `throw` the rejection reason for the nearest Error Boundary to handle.
34+
* `load`: Функция, которая возвращает [Промис](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Promise) или другой *thenable* (объект, в котором определен метод `then`). Вызова `load` не произойдет до тех пор, пока вы не попытаетесь отрендерить возвращённый компонент. После первого вызова `load`, React будет ждать завершения выполнения команды, а затем отрендерит разрешённое значение как React-компонент. Возвращаемый промис и разрешенное значение промиса будут кэшироваться, поэтому React не будет вызывать `load` более одного раза. Если Promise отклоняется, React укажет причину в ближайшем Error Boundary.
3635

37-
#### Returns {/*returns*/}
36+
#### Возвращаемое значение {/*returns*/}
3837

39-
`lazy` returns a React component you can render in your tree. While the code for the lazy component is still loading, attempting to render it will *suspend.* Use [`<Suspense>`](/reference/react/Suspense) to display a loading indicator while it's loading.
38+
`lazy` возвращает React-компонент, который можно отрендерить в вашем дереве. Пока код для ленивого компонента все еще загружается, попытка его отрисовки *приостанавливается.* Используйте [`<Suspense>`](/reference/react/Suspense) для отображения индикатора загрузки во время загрузки.
4039

4140
---
4241

43-
### `load` function {/*load*/}
42+
### Функция `load` {/*load*/}
4443

45-
#### Parameters {/*load-parameters*/}
44+
#### Параметры {/*load-parameters*/}
4645

47-
`load` receives no parameters.
46+
`load` не принимает параметров.
4847

49-
#### Returns {/*load-returns*/}
48+
#### Возвращаемое значение {/*load-returns*/}
5049

51-
You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or some other *thenable* (a Promise-like object with a `then` method). It needs to eventually resolve to a valid React component type, such as a function, [`memo`](/reference/react/memo), or a [`forwardRef`](/reference/react/forwardRef) component.
50+
Возвращает [Промис](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Promise) или другой *thenable* (объект, в котором определен метод `then`). В конечном итоге он вернётся к действительному React компоненту, например к функции, [`memo`](/reference/react/memo), или [`forwardRef`](/reference/react/forwardRef) компоненту.
5251

5352
---
5453

55-
## Usage {/*usage*/}
54+
## Использование {/*usage*/}
5655

57-
### Lazy-loading components with Suspense {/*suspense-for-code-splitting*/}
56+
### Ленивая загрузка компонентов с Suspense {/*suspense-for-code-splitting*/}
5857

59-
Usually, you import components with the static [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) declaration:
58+
Обычно импорт компонентов происходит со статическим [`import`](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/import) объявлением:
6059

6160
```js
6261
import MarkdownPreview from './MarkdownPreview.js';
6362
```
6463

65-
To defer loading this component's code until it's rendered for the first time, replace this import with:
64+
Чтобы отложить загрузку кода этого компонента до его первого рендеринга, замените этот импорт на:
6665

6766
```js
6867
import { lazy } from 'react';
6968

7069
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
7170
```
7271

73-
This code relies on [dynamic `import()`,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) which might require support from your bundler or framework.
72+
Этот код опирается на [динамический `import()`,](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) который должен поддерживаться вашим бандлером или фреймворком.
7473

75-
Now that your component's code loads on demand, you also need to specify what should be displayed while it is loading. You can do this by wrapping the lazy component or any of its parents into a [`<Suspense>`](/reference/react/Suspense) boundary:
74+
Теперь, когда код вашего компонента загружается по запросу, вам также необходимо указать, что должно отображаться во время его загрузки. Это можно сделать путем оборачивания ленивого компонента или его родителя в границы [`<Suspense>`](/reference/react/Suspense):
7675

7776
```js {1,4}
7877
<Suspense fallback={<Loading />}>
@@ -81,7 +80,7 @@ Now that your component's code loads on demand, you also need to specify what sh
8180
</Suspense>
8281
```
8382

84-
In this example, the code for `MarkdownPreview` won't be loaded until you attempt to render it. If `MarkdownPreview` hasn't loaded yet, `Loading` will be shown in its place. Try ticking the checkbox:
83+
Например, код для `MarkdownPreview` не загрузится, пока его не попытаются вызвать. Если `MarkdownPreview` ещё не загрузился, на его месте отобразится `Loading`. Попробуйте поставить галочку в чекбоксе:
8584

8685
<Sandpack>
8786

@@ -112,7 +111,7 @@ export default function MarkdownEditor() {
112111
);
113112
}
114113

115-
// Add a fixed delay so you can see the loading state
114+
// Добавьте фиксированную задержку, чтобы увидеть загрузку
116115
function delayForDemo(promise) {
117116
return new Promise(resolve => {
118117
setTimeout(resolve, 2000);
@@ -175,34 +174,34 @@ body {
175174

176175
</Sandpack>
177176

178-
This demo loads with an artificial delay. The next time you untick and tick the checkbox, `Preview` will be cached, so there will be no loading state. To see the loading state again, click "Reset" on the sandbox.
177+
Это демо загрузится с искусственной задержкой. В следующий раз когда вы снимите и поставите галочку, `Preview` будет закэшировано, загрузки не будет. Чтобы снова увидеть загрузку, нужно нажать "Reset" в сандбоксе.
179178

180-
[Learn more about managing loading states with Suspense.](/reference/react/Suspense)
179+
[Узнать об управлении состояниями загрузки с помощью Suspense.](/reference/react/Suspense)
181180

182181
---
183182

184-
## Troubleshooting {/*troubleshooting*/}
183+
## Траблшутинг {/*troubleshooting*/}
185184

186-
### My `lazy` component's state gets reset unexpectedly {/*my-lazy-components-state-gets-reset-unexpectedly*/}
185+
### Состояние моего `lazy` компонента неожиданно сбрасывается {/*my-lazy-components-state-gets-reset-unexpectedly*/}
187186

188-
Do not declare `lazy` components *inside* other components:
187+
Не объявляйте `lazy` компоненты *внутри* других компонентов:
189188

190189
```js {4-5}
191190
import { lazy } from 'react';
192191

193192
function Editor() {
194-
// 🔴 Bad: This will cause all state to be reset on re-renders
193+
// 🔴 Плохо: Все состояния сбросятся при ре-рендере
195194
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
196195
// ...
197196
}
198197
```
199198

200-
Instead, always declare them at the top level of your module:
199+
Вместо этого всегда объявляйте их в верхнем уровне своего модуля:
201200

202201
```js {3-4}
203202
import { lazy } from 'react';
204203

205-
//Good: Declare lazy components outside of your components
204+
//Хорошо: lazy компонент объявлен вне ваших компонентов.
206205
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
207206

208207
function Editor() {

0 commit comments

Comments
 (0)