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: content/blog/2022-03-08-react-18-upgrade-guide.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ Finally, this API will continue to work for rendering e-mails:
125
125
126
126
For more information on the changes to server rendering APIs, see the working group post on [Upgrading to React 18 on the server](https://github.com/reactwg/react-18/discussions/22), a [deep dive on the new Suspense SSR Architecture](https://github.com/reactwg/react-18/discussions/37), and [Shaundai Person’s](https://twitter.com/shaundai) talk on [Streaming Server Rendering with Suspense](https://www.youtube.com/watch?v=pj5N-Khihgc) at React Conf 2021.
127
127
128
-
## Updates to TypeScript definitions
128
+
## Updates to TypeScript definitions {#updates-to-typescript-definitions}
129
129
130
130
If your project uses TypeScript, you will need to update your `@types/react` and `@types/react-dom` dependencies to the latest versions. The new types are safer and catch issues that used to be ignored by the type checker. The most notable change is that the `children` prop now needs to be listed explicitly when defining props, for example:
Copy file name to clipboardExpand all lines: content/docs/accessibility.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -401,11 +401,7 @@ class BlurExample extends React.Component {
401
401
-[всё о цветовой контрастности и о том, почему вы должны переосмыслить подход к ней](https://www.smashingmagazine.com/2014/10/color-contrast-tips-and-tools-for-accessibility/)
402
402
-[статья о цветовой контрастности на сайте A11y Project](https://a11yproject.com/posts/what-is-color-contrast/)
403
403
404
-
<<<<<<< HEAD
405
-
Ручной расчёт правильных цветовых комбинаций для всех вариантов сайта может быть очень утомительным. Вместо этого вы можете рассчитать все необходимые палитры [с помощью Colorable](https://jxnblk.com/colorable/).
406
-
=======
407
-
It can be tedious to manually calculate the proper color combinations for all cases in your website so instead, you can [calculate an entire accessible color palette with Colorable](https://colorable.jxnblk.com/).
408
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
404
+
Ручной расчёт правильных цветовых комбинаций для всех вариантов сайта может быть очень утомительным. Вместо этого вы можете рассчитать все необходимые палитры [с помощью Colorable](https://colorable.jxnblk.com/).
409
405
410
406
Оба инструмента, aXe и WAVE, о которых будет рассказано ниже, включают тесты контрастности. Они помогут выявить ошибки в подборе цветов.
Мы не будем пользоваться сложными инструментами сборки или что-то устанавливать. **Всё, что вам нужно -- это доступ к Интернету и минута свободного времени**.
27
27
28
-
<<<<<<< HEAD
29
-
Необязательно: [скачать готовый пример (архив 2 Кбайт)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/f6c882b6ae18bde42dcf6fdb751aae93495a2275.zip)
30
-
=======
31
-
Optional: [Download the full example (2KB zipped)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/87f0b6f34238595b44308acfb86df6ea43669c08.zip)
32
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
28
+
Необязательно: [скачать готовый пример (архив 2 Кбайт)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/87f0b6f34238595b44308acfb86df6ea43669c08.zip)
33
29
34
30
### Шаг 1: Добавляем DOM-контейнер в HTML {#step-1-add-a-dom-container-to-the-html}
35
31
@@ -56,17 +52,10 @@ Optional: [Download the full example (2KB zipped)](https://gist.github.com/gaear
56
52
```html{5,6,9}
57
53
<!-- ... остальной HTML ... -->
58
54
59
-
<<<<<<< HEAD
60
55
<!-- Загрузим React. -->
61
56
<!-- Примечание: при деплое на продакшен замените «development.js» на «production.min.js». -->
@@ -86,28 +75,17 @@ Optional: [Download the full example (2KB zipped)](https://gist.github.com/gaear
86
75
>
87
76
>В данном коде создаётся React-компонент с именем `LikeButton`. Не беспокойтесь, если что-то кажется вам непонятным -- мы подробно разберём принципы разработки на React позже, в нашем [практическом руководстве](/tutorial/tutorial.html) и во [введении в основные понятия](/docs/hello-world.html). Пока же мы просто посмотрим, как это выглядит на экране.
88
77
89
-
<<<<<<< HEAD
90
-
Добавьте ещё 2 строки в конец файла `like_button.js`, после **[стартового кода](https://gist.github.com/gaearon/0b180827c190fe4fd98b4c7f570ea4a8/raw/b9157ce933c79a4559d2aa9ff3372668cce48de7/LikeButton.js)**:
91
-
92
-
```js{3,4}
93
-
// ... стартовый код ...
94
-
=======
95
-
After **[the starter code](https://gist.github.com/gaearon/0b180827c190fe4fd98b4c7f570ea4a8/raw/b9157ce933c79a4559d2aa9ff3372668cce48de7/LikeButton.js)**, add three lines to the bottom of `like_button.js`:
78
+
Добавьте ещё 3 строки в конец файла `like_button.js`, после **[стартового кода](https://gist.github.com/gaearon/0b180827c190fe4fd98b4c7f570ea4a8/raw/b9157ce933c79a4559d2aa9ff3372668cce48de7/LikeButton.js)**:
Эти две строки кода ищут элемент `<div>`, который мы добавили на первом шаге, а затем отображают React-компонент с кнопкой "Нравится" внутри него.
108
-
=======
109
-
These three lines of code find the `<div>` we added to our HTML in the first step, create a React app with it, and then display our "Like" button React component inside of it.
110
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
88
+
Эти три строки кода ищут элемент `<div>`, который мы добавили в HTML на первом шаге, а затем отображают React-компонент с кнопкой "Нравится" внутри него.
111
89
112
90
### Готово! {#thats-it}
113
91
@@ -117,23 +95,15 @@ These three lines of code find the `<div>` we added to our HTML in the first ste
117
95
118
96
**[Посмотреть финальный код примера](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605)**
119
97
120
-
<<<<<<< HEAD
121
-
**[Скачать код примера (архив 2 Кбайт)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/f6c882b6ae18bde42dcf6fdb751aae93495a2275.zip)**
122
-
=======
123
-
**[Download the full example (2KB zipped)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/87f0b6f34238595b44308acfb86df6ea43669c08.zip)**
124
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
98
+
**[Скачать код примера (архив 2 Кбайт)](https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605/archive/87f0b6f34238595b44308acfb86df6ea43669c08.zip)**
125
99
126
100
### Совет: Повторное использование компонентов {#tip-reuse-a-component}
127
101
128
102
Зачастую, вам может понадобиться отобразить React-компонент в нескольких местах одной и той же HTML-страницы. Вот как можно показать сразу три кнопки «Нравится» с разными данными:
129
103
130
104
[Посмотреть исходный код примера](https://gist.github.com/gaearon/faa67b76a6c47adbab04f739cba7ceda)
131
105
132
-
<<<<<<< HEAD
133
-
[Скачать код примера (архив 2 Кбайт)](https://gist.github.com/gaearon/faa67b76a6c47adbab04f739cba7ceda/archive/9d0dd0ee941fea05fd1357502e5aa348abb84c12.zip)
134
-
=======
135
-
[Download the full example (2KB zipped)](https://gist.github.com/gaearon/faa67b76a6c47adbab04f739cba7ceda/archive/279839cb9891bd41802ebebc5365e9dec08eeb9f.zip)
136
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
106
+
[Скачать код примера (архив 2 Кбайт)](https://gist.github.com/gaearon/faa67b76a6c47adbab04f739cba7ceda/archive/279839cb9891bd41802ebebc5365e9dec08eeb9f.zip)
Вы можете думать о shallowRenderer как о «месте» в которое рендерится тестируемый компонент, и из которого вы можете извлечь результат вывода этого компонента.
61
61
62
-
<<<<<<< HEAD
63
-
`shallowRenderer.render()` схож с [`ReactDOM.render()`](/docs/react-dom.html#render), но не требует DOM и рендерит всего один уровень глубины. Это означает что вы можете тестировать компоненты независимо от того, как реализованы их дочерние компоненты.
64
-
=======
65
-
`shallowRenderer.render()` is similar to [`root.render()`](/docs/react-dom-client.html#createroot) but it doesn't require DOM and only renders a single level deep. This means you can test components isolated from how their children are implemented.
66
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
62
+
`shallowRenderer.render()` схож с [`root.render()`](/docs/react-dom-client.html#createroot), но не требует DOM и рендерит всего один уровень глубины. Это означает что вы можете тестировать компоненты независимо от того, как реализованы их дочерние компоненты.
> Возможности `React.lazy` и задержки (suspense) пока недоступны для рендеринга на стороне сервера. Если вам нужно разделение кода в серверном приложении, мы рекомендуем [Loadable Components](https://github.com/gregberge/loadable-components). У них есть хорошее [руководство по разделению бандла](https://loadable-components.com/docs/server-side-rendering/) с серверным рендерингом.
89
-
90
85
Функция `React.lazy` позволяет рендерить динамический импорт как обычный компонент.
91
-
=======
92
-
The `React.lazy` function lets you render a dynamic import as a regular component.
93
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
94
86
95
87
**До:**
96
88
@@ -150,9 +142,6 @@ function MyComponent() {
150
142
}
151
143
```
152
144
153
-
<<<<<<< HEAD
154
-
### Предохранители {#error-boundaries}
155
-
=======
156
145
### Avoiding fallbacks {#avoiding-fallbacks}
157
146
Any component may suspend as a result of rendering, even components that were already shown to the user. In order for screen content to always be consistent, if an already shown component suspends, React has to hide its tree up to the closest `<Suspense>` boundary. However, from the user's perspective, this can be disorienting.
158
147
@@ -199,9 +188,7 @@ function handleTabSelect(tab) {
199
188
200
189
Here, you tell React that setting tab to `'comments'` is not an urgent update, but is a [transition](/docs/react-api.html#transitions) that may take some time. React will then keep the old UI in place and interactive, and will switch to showing `<Comments />` when it is ready. See [Transitions](/docs/react-api.html#transitions) for more info.
201
190
202
-
### Error boundaries {#error-boundaries}
203
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
204
-
191
+
### Предохранители {#error-boundaries}
205
192
206
193
Если какой-то модуль не загружается (например, из-за сбоя сети), это вызовет ошибку. Вы можете обрабатывать эти ошибки для улучшения пользовательского опыта с помощью [Предохранителей](/docs/error-boundaries.html). После создания предохранителя, его можно использовать в любом месте над ленивыми компонентами для отображения состояния ошибки.
Copy file name to clipboardExpand all lines: content/docs/error-boundaries.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,11 +65,7 @@ class ErrorBoundary extends React.Component {
65
65
66
66
## Живой пример {#live-demo}
67
67
68
-
<<<<<<< HEAD
69
-
Посмотрите [пример объявления и использования предохранителя](https://codepen.io/gaearon/pen/wqvxGa?editors=0010) в [React 16](/blog/2017/09/26/react-v16.0.html).
70
-
=======
71
-
Check out [this example of declaring and using an error boundary](https://codepen.io/gaearon/pen/wqvxGa?editors=0010).
72
-
>>>>>>> 26caa649827e8f8cadd24dfc420ea802dcbee246
68
+
Посмотрите [пример объявления и использования предохранителя](https://codepen.io/gaearon/pen/wqvxGa?editors=0010).
73
69
74
70
## Где размещать предохранители {#where-to-place-error-boundaries}
0 commit comments