From f453d50e9a56b99eb7b8c97cca785c7526f6c8de Mon Sep 17 00:00:00 2001
From: "translate-react-bot[bot]"
<251169733+translate-react-bot[bot]@users.noreply.github.com>
Date: Tue, 2 Jun 2026 14:19:43 +0000
Subject: [PATCH] =?UTF-8?q?docs:=20translate=20`queueing-a-series-of-state?=
=?UTF-8?q?-updates.md`=20to=20=D0=A0=D1=83=D1=81=D1=81=D0=BA=D0=B8=D0=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../queueing-a-series-of-state-updates.md | 152 +++++++++---------
1 file changed, 76 insertions(+), 76 deletions(-)
diff --git a/src/content/learn/queueing-a-series-of-state-updates.md b/src/content/learn/queueing-a-series-of-state-updates.md
index 41de6529a6..0ddb143f57 100644
--- a/src/content/learn/queueing-a-series-of-state-updates.md
+++ b/src/content/learn/queueing-a-series-of-state-updates.md
@@ -4,20 +4,20 @@ title: Queueing a Series of State Updates
-Setting a state variable will queue another render. But sometimes you might want to perform multiple operations on the value before queueing the next render. To do this, it helps to understand how React batches state updates.
+Установка переменной состояния инициирует следующий рендер. Но иногда вам может понадобиться выполнить несколько операций со значением перед тем, как инициировать следующий рендер. Для этого полезно понять, как React группирует обновления состояния.
-* What "batching" is and how React uses it to process multiple state updates
-* How to apply several updates to the same state variable in a row
+* Что такое «группировка» (batching) и как React использует её для обработки нескольких обновлений состояния
+* Как применить несколько обновлений к одной и той же переменной состояния подряд
-## React batches state updates {/*react-batches-state-updates*/}
+## React группирует обновления состояния {/*react-batches-state-updates*/}
-You might expect that clicking the "+3" button will increment the counter three times because it calls `setNumber(number + 1)` three times:
+Вы можете ожидать, что нажатие кнопки «+3» увеличит счётчик три раза, поскольку она трижды вызывает `setNumber(number + 1)`:
@@ -47,7 +47,7 @@ h1 { display: inline-block; margin: 10px; width: 30px; text-align: center; }
-However, as you might recall from the previous section, [each render's state values are fixed](/learn/state-as-a-snapshot#rendering-takes-a-snapshot-in-time), so the value of `number` inside the first render's event handler is always `0`, no matter how many times you call `setNumber(1)`:
+Однако, как вы могли вспомнить из предыдущего раздела, [значения состояния для каждого рендера фиксированы](/learn/state-as-a-snapshot#rendering-takes-a-snapshot-in-time), поэтому значение `number` внутри обработчика события первого рендера всегда равно `0`, независимо от того, сколько раз вы вызываете `setNumber(1)`:
```js
setNumber(0 + 1);
@@ -55,21 +55,21 @@ setNumber(0 + 1);
setNumber(0 + 1);
```
-But there is one other factor at play here. **React waits until *all* code in the event handlers has run before processing your state updates.** This is why the re-render only happens *after* all these `setNumber()` calls.
+Но здесь действует ещё один фактор. **React ждёт, пока весь код в обработчиках событий не будет выполнен, прежде чем обрабатывать ваши обновления состояния.** Вот почему повторный рендер происходит только *после* всех этих вызовов `setNumber()`.
-This might remind you of a waiter taking an order at the restaurant. A waiter doesn't run to the kitchen at the mention of your first dish! Instead, they let you finish your order, let you make changes to it, and even take orders from other people at the table.
+Это может напомнить вам официанта, принимающего заказ в ресторане. Официант не бежит на кухню при упоминании вашего первого блюда! Вместо этого он позволяет вам закончить заказ, внести в него изменения и даже принять заказы от других людей за столом.
-
+
-This lets you update multiple state variables--even from multiple components--without triggering too many [re-renders.](/learn/render-and-commit#re-renders-when-state-updates) But this also means that the UI won't be updated until _after_ your event handler, and any code in it, completes. This behavior, also known as **batching,** makes your React app run much faster. It also avoids dealing with confusing "half-finished" renders where only some of the variables have been updated.
+Это позволяет вам обновлять несколько переменных состояния — даже из нескольких компонентов — без вызова слишком большого количества [повторных рендеров](/learn/render-and-commit#re-renders-when-state-updates). Но это также означает, что пользовательский интерфейс не будет обновлён до тех пор, пока ваш обработчик события и весь код в нём не завершатся. Это поведение, также известное как **группировка (batching)**, делает ваше React-приложение намного быстрее. Оно также позволяет избежать путаницы с «незавершёнными» рендерами, когда обновлены только некоторые переменные.
-**React does not batch across *multiple* intentional events like clicks**--each click is handled separately. Rest assured that React only does batching when it's generally safe to do. This ensures that, for example, if the first button click disables a form, the second click would not submit it again.
+**React не группирует обновления между *несколькими* намеренными событиями, такими как клики** — каждый клик обрабатывается отдельно. Будьте уверены, что React группирует обновления только тогда, когда это в целом безопасно. Это гарантирует, что, например, если первый клик по кнопке отключает форму, второй клик не отправит её снова.
-## Updating the same state multiple times before the next render {/*updating-the-same-state-multiple-times-before-the-next-render*/}
+## Обновление одного и того же состояния несколько раз перед следующим рендером {/*updating-the-same-state-multiple-times-before-the-next-render*/}
-It is an uncommon use case, but if you would like to update the same state variable multiple times before the next render, instead of passing the *next state value* like `setNumber(number + 1)`, you can pass a *function* that calculates the next state based on the previous one in the queue, like `setNumber(n => n + 1)`. It is a way to tell React to "do something with the state value" instead of just replacing it.
+Это редкий сценарий использования, но если вы хотите обновить одну и ту же переменную состояния несколько раз перед следующим рендером, вместо передачи *следующего значения состояния*, как `setNumber(number + 1)`, вы можете передать *функцию*, которая вычисляет следующее состояние на основе предыдущего в очереди, например `setNumber(n => n + 1)`. Это способ сказать React «сделай что-нибудь со значением состояния», а не просто заменить его.
-Try incrementing the counter now:
+Попробуйте увеличить счётчик сейчас:
@@ -99,10 +99,10 @@ h1 { display: inline-block; margin: 10px; width: 30px; text-align: center; }
-Here, `n => n + 1` is called an **updater function.** When you pass it to a state setter:
+Здесь `n => n + 1` называется **функцией обновления (updater function)**. Когда вы передаёте её установщику состояния:
-1. React queues this function to be processed after all the other code in the event handler has run.
-2. During the next render, React goes through the queue and gives you the final updated state.
+1. React ставит эту функцию в очередь для обработки после всего остального кода в обработчике события.
+2. Во время следующего рендера React проходит по очереди и предоставляет вам окончательное обновлённое состояние.
```js
setNumber(n => n + 1);
@@ -110,26 +110,26 @@ setNumber(n => n + 1);
setNumber(n => n + 1);
```
-Here's how React works through these lines of code while executing the event handler:
+Вот как React обрабатывает эти строки кода при выполнении обработчика события:
-1. `setNumber(n => n + 1)`: `n => n + 1` is a function. React adds it to a queue.
-1. `setNumber(n => n + 1)`: `n => n + 1` is a function. React adds it to a queue.
-1. `setNumber(n => n + 1)`: `n => n + 1` is a function. React adds it to a queue.
+1. `setNumber(n => n + 1)`: `n => n + 1` — это функция. React добавляет её в очередь.
+1. `setNumber(n => n + 1)`: `n => n + 1` — это функция. React добавляет её в очередь.
+1. `setNumber(n => n + 1)`: `n => n + 1` — это функция. React добавляет её в очередь.
-When you call `useState` during the next render, React goes through the queue. The previous `number` state was `0`, so that's what React passes to the first updater function as the `n` argument. Then React takes the return value of your previous updater function and passes it to the next updater as `n`, and so on:
+Когда вы вызываете `useState` во время следующего рендера, React проходит по очереди. Предыдущее состояние `number` было `0`, поэтому именно это значение React передаёт первой функции обновления в качестве аргумента `n`. Затем React берёт возвращаемое значение предыдущей функции обновления и передаёт его следующей функции обновления в качестве `n`, и так далее:
-| queued update | `n` | returns |
+| поставленная в очередь операция | `n` | возвращает |
|--------------|---------|-----|
| `n => n + 1` | `0` | `0 + 1 = 1` |
| `n => n + 1` | `1` | `1 + 1 = 2` |
| `n => n + 1` | `2` | `2 + 1 = 3` |
-React stores `3` as the final result and returns it from `useState`.
+React сохраняет `3` как окончательный результат и возвращает его из `useState`.
-This is why clicking "+3" in the above example correctly increments the value by 3.
-### What happens if you update state after replacing it {/*what-happens-if-you-update-state-after-replacing-it*/}
+Вот почему нажатие «+3» в приведенном выше примере корректно увеличивает значение на 3.
+### Что происходит, если вы обновляете состояние после его замены {/*what-happens-if-you-update-state-after-replacing-it*/}
-What about this event handler? What do you think `number` will be in the next render?
+А как насчёт этого обработчика события? Как вы думаете, каким будет `number` в следующем рендере?
```js