From f063b40ae570e76df3b196e19f194cfc04506214 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com>
Date: Sun, 19 May 2024 11:11:36 +0800
Subject: [PATCH 01/16] docs(cn): translate blog/2024/04/25/react-19 into
Chinese
---
src/content/blog/2024/04/25/react-19.md | 269 ++++++++++++------------
1 file changed, 134 insertions(+), 135 deletions(-)
diff --git a/src/content/blog/2024/04/25/react-19.md b/src/content/blog/2024/04/25/react-19.md
index 8224cfe9e0..033c55409a 100644
--- a/src/content/blog/2024/04/25/react-19.md
+++ b/src/content/blog/2024/04/25/react-19.md
@@ -2,42 +2,42 @@
title: "React 19 Beta"
author: The React Team
date: 2024/04/25
-description: React 19 Beta is now available on npm! In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
+description: React 19 测试版现在可以在 npm 上使用了! 在这篇文章中,我们将概述 React 19 的新特性,以及如何使用它们。
---
-April 25, 2024 by [The React Team](/community/team)
+2023 年 4 月 25 日 [The React Team](/community/team)
---
-This beta release is for libraries to prepare for React 19. App developers should upgrade to 18.3.0 and wait for React 19 stable as we work with libraries and make changes based on feedback.
+这个测试版的发布是为了 React 19 的库做准备。应用开发者应该升级到 18.3.0,并等待 React 19 稳定版发布,因为我们正在维护这个库,并根据反馈进行更改。
-React 19 Beta is now available on npm!
+React 19 测试版现在可以在 npm 上使用了!
-In our [React 19 Beta Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide), we shared step-by-step instructions for upgrading your app to React 19 Beta. In this post, we'll give an overview of the new features in React 19, and how you can adopt them.
+在我们的 [React 19 Beta 升级指南](/blog/2024/04/25/react-19-upgrade-guide) 中,我们分享了将您的应用升级到 React 19 Beta 的逐步指南。在这篇文章中,我们将概述 React 19 中的新功能,以及您如何采用它们。
-- [What's new in React 19](#whats-new-in-react-19)
-- [Improvements in React 19](#improvements-in-react-19)
-- [How to upgrade](#how-to-upgrade)
+- [React 19 中的新功能](#whats-new-in-react-19)
+- [React 19 中的改进](#improvements-in-react-19)
+- [如何升级](#how-to-upgrade)
-For a list of breaking changes, see the [Upgrade Guide](/blog/2024/04/25/react-19-upgrade-guide).
+有关破坏性更改的列表,请参阅 [升级指南](/blog/2024/04/25/react-19-upgrade-guide).
---
-## What's new in React 19 {/*whats-new-in-react-19*/}
+## React 19 中的新功能 {/*whats-new-in-react-19*/}
### Actions {/*actions*/}
-A common use case in React apps is to perform a data mutation and then update state in response. For example, when a user submits a form to change their name, you will make an API request, and then handle the response. In the past, you would need to handle pending states, errors, optimistic updates, and sequential requests manually.
+在 React 应用中,一个常见的用例是执行数据变更,然后响应更新状态。例如,当用户提交一个表单来更改他们的名字,你会发起一个 API 请求,然后处理响应。在过去,你需要手动处理待处理状态、错误、乐观更新和顺序请求。
-For example, you could handle the pending and error state in `useState`:
+例如,你可以在 `useState` 中处理待处理和错误状态:
```js
// Before Actions
@@ -69,12 +69,12 @@ function UpdateName({}) {
}
```
-In React 19, we're adding support for using async functions in transitions to handle pending states, errors, forms, and optimistic updates automatically.
+在 React 19 中,我们添加了在过渡中使用异步函数的支持,以自动处理待处理状态、错误、表单和乐观更新。
-For example, you can use `useTransition` to handle the pending state for you:
+例如,你可以使用 `useTransition` 来为你处理待处理状态:
```js
-// Using pending state from Actions
+// 使用 Actions 中的待处理状态
function UpdateName({}) {
const [name, setName] = useState("");
const [error, setError] = useState(null);
@@ -103,24 +103,24 @@ function UpdateName({}) {
}
```
-The async transition will immediately set the `isPending` state to true, make the async request(s), and switch `isPending` to false after any transitions. This allows you to keep the current UI responsive and interactive while the data is changing.
+异步过渡会立即将 `isPending` 状态设置为 true,发出异步请求,然后在任何过渡后将 `isPending` 切换为 `false`。这使你能够在数据变化时保持当前 UI 的响应性和交互性。
-#### By convention, functions that use async transitions are called "Actions". {/*by-convention-functions-that-use-async-transitions-are-called-actions*/}
+#### 按照惯例,使用异步过渡的函数被称为 "Actions"。 {/*by-convention-functions-that-use-async-transitions-are-called-actions*/}
-Actions automatically manage submitting data for you:
+Actions 自动为你管理数据提交:
-- **Pending state**: Actions provide a pending state that starts at the beginning of a request and automatically resets when the final state update is committed.
-- **Optimistic updates**: Actions support the new [`useOptimistic`](#new-hook-optimistic-updates) hook so you can show users instant feedback while the requests are submitting.
-- **Error handling**: Actions provide error handling so you can display Error Boundaries when a request fails, and revert optimistic updates to their original value automatically.
-- **Forms**: `
-Building on top of Actions, React 19 introduces [`useOptimistic`](#new-hook-optimistic-updates) to manage optimistic updates, and a new hook [`React.useActionState`](#new-hook-useactionstate) to handle common cases for Actions. In `react-dom` we're adding [`