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
Функция `startTransition` позволяет пометить обновление состояния как переход.
25
-
=======
26
-
The `startTransition` function lets you mark a state update as a Transition.
27
-
>>>>>>> 97489434323b0c4cce78588cd0f48e3808e0eba4
28
24
29
25
```js {7,9}
30
26
import { startTransition } from'react';
@@ -45,57 +41,33 @@ function TabContainer() {
45
41
46
42
#### Параметры {/*parameters*/}
47
43
48
-
<<<<<<< HEAD
49
-
*`scope`: Функция, которая обновляет состояние, вызывая одну или несколько [функций `set`.](/reference/react/useState#setstate) React немедленно вызывает `scope` без аргументов и помечает все обновления состояния, запланированные синхронно во время вызова функции scope, как переходы. Они будут [неблокирующими](/reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition) и [не будут отображать нежелательные индикаторы загрузки.](/reference/react/useTransition#preventing-unwanted-loading-indicators)
50
-
=======
51
-
*`scope`: A function that updates some state by calling one or more [`set` functions.](/reference/react/useState#setstate) React immediately calls `scope` with no arguments and marks all state updates scheduled synchronously during the `scope` function call as Transitions. They will be [non-blocking](/reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition) and [will not display unwanted loading indicators.](/reference/react/useTransition#preventing-unwanted-loading-indicators)
52
-
>>>>>>> 97489434323b0c4cce78588cd0f48e3808e0eba4
44
+
*`scope`: Функция, которая обновляет состояние, вызывая одну или несколько [функций `set`.](/reference/react/useState#setstate) React немедленно вызывает `scope` без параметров и помечает все обновления состояния, запланированные синхронно во время вызова функции scope, как переходы. Они будут [неблокирующими](/reference/react/useTransition#marking-a-state-update-as-a-non-blocking-transition) и [не будут отображать нежелательные индикаторы загрузки.](/reference/react/useTransition#preventing-unwanted-loading-indicators)
53
45
54
46
#### Возвращаемое значение {/*returns*/}
55
47
56
48
`startTransition` ничего не возвращает.
57
49
58
50
#### Замечания {/*caveats*/}
59
51
60
-
<<<<<<< HEAD
61
52
*`startTransition` не предоставляет способа отслеживать, ожидает ли переход выполнения. Чтобы показать индикатор ожидания во время выполнения перехода, необходимо использовать [`useTransition`](/reference/react/useTransition).
62
53
63
54
* Вы можете обернуть обновление в переход только в том случае, если у вас есть доступ к функции `set` для этого состояния. Если вы хотите начать переход в ответ на какой-то проп или значение, возвращаемое пользовательским хуком, попробуйте использовать [`useDeferredValue`](/reference/react/useDeferredValue).
64
55
65
56
* Функция, передаваемая в `startTransition`, должна быть синхронной. React немедленно выполняет эту функцию, помечая как переходы все обновления состояния которые происходят во время ее выполнения. Если вы попытаетесь выполнить дополнительные обновления состояния позже (например, в таймауте), они не будут помечены как переходы.
66
57
67
58
* Обновление состояния, помеченное как переход, будет прервано другими обновлениями состояния. Например, если вы обновите компонент диаграммы внутри перехода, но затем начнете вводить текст в поле ввода, пока диаграмма находится в процессе повторного рендеринга, React перезапустит процесс рендеринга компонента диаграммы после обработки обновления состояния в поле ввода.
68
-
=======
69
-
*`startTransition` does not provide a way to track whether a Transition is pending. To show a pending indicator while the Transition is ongoing, you need [`useTransition`](/reference/react/useTransition) instead.
70
-
71
-
* You can wrap an update into a Transition only if you have access to the `set` function of that state. If you want to start a Transition in response to some prop or a custom Hook return value, try [`useDeferredValue`](/reference/react/useDeferredValue) instead.
72
-
73
-
* The function you pass to `startTransition` must be synchronous. React immediately executes this function, marking all state updates that happen while it executes as Transitions. If you try to perform more state updates later (for example, in a timeout), they won't be marked as Transitions.
74
-
75
-
* A state update marked as a Transition will be interrupted by other state updates. For example, if you update a chart component inside a Transition, but then start typing into an input while the chart is in the middle of a re-render, React will restart the rendering work on the chart component after handling the input state update.
76
-
>>>>>>> 97489434323b0c4cce78588cd0f48e3808e0eba4
77
59
78
60
* Обновления перехода не могут использоваться для управления текстовыми полями ввода.
79
61
80
-
<<<<<<< HEAD
81
62
* В случае наличия нескольких одновременных переходов, React в настоящее время группирует их вместе. Это ограничение, вероятно, будет устранено в будущих релизах.
82
-
=======
83
-
* If there are multiple ongoing Transitions, React currently batches them together. This is a limitation that will likely be removed in a future release.
84
-
>>>>>>> 97489434323b0c4cce78588cd0f48e3808e0eba4
85
63
86
64
---
87
65
88
66
## Применение {/*usage*/}
89
67
90
-
<<<<<<< HEAD
91
68
### Пометка обновления состояния как неблокирующего перехода. {/*marking-a-state-update-as-a-non-blocking-transition*/}
92
69
93
70
Вы можете пометить обновление состояния как *переход*, обернув его в вызов `startTransition`:
94
-
=======
95
-
### Marking a state update as a non-blocking Transition {/*marking-a-state-update-as-a-non-blocking-transition*/}
96
-
97
-
You can mark a state update as a *Transition* by wrapping it in a `startTransition` call:
98
-
>>>>>>> 97489434323b0c4cce78588cd0f48e3808e0eba4
99
71
100
72
```js {7,9}
101
73
import { startTransition } from'react';
@@ -114,22 +86,12 @@ function TabContainer() {
114
86
115
87
Переходы позволяют сохранить отзывчивость обновлений интерфейса даже на медленных устройствах.
116
88
117
-
<<<<<<< HEAD
118
89
С помощью перехода ваш UI остается отзывчивым даже во время повторного рендера. Например, если пользователь нажимает на вкладку, но затем меняет свое решение и нажимает на другую вкладку, он может это сделать, не дожидаясь завершения первого перерендеринга.
119
90
120
91
<Note>
121
92
122
93
`startTransition` очень похож на [`useTransition`](/reference/react/useTransition), за исключением того, что он не предоставляет флаг `isPending` для отслеживания того, идет ли в данный момент переход. Вы можете вызвать `startTransition`, когда `useTransition` недоступен. Например, `startTransition` работает вне компонентов из например, библиотеки данных.
123
94
124
95
[Узнайте о переходах и посмотрите примеры на странице `useTransition`.](/reference/react/useTransition)
125
-
=======
126
-
With a Transition, your UI stays responsive in the middle of a re-render. For example, if the user clicks a tab but then change their mind and click another tab, they can do that without waiting for the first re-render to finish.
127
-
128
-
<Note>
129
-
130
-
`startTransition` is very similar to [`useTransition`](/reference/react/useTransition), except that it does not provide the `isPending` flag to track whether a Transition is ongoing. You can call `startTransition` when `useTransition` is not available. For example, `startTransition` works outside components, such as from a data library.
131
-
132
-
[Learn about Transitions and see examples on the `useTransition` page.](/reference/react/useTransition)
0 commit comments