Skip to content

Commit 7c9ba4e

Browse files
fix conflicts
1 parent f5ec447 commit 7c9ba4e

9 files changed

+11
-110
lines changed

src/content/learn/creating-a-react-app.md

+3-31
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,19 @@ title: 创建一个 React 应用
88

99
</Intro>
1010

11-
<<<<<<< HEAD
12-
## 推荐的 React 框架 {/*bleeding-edge-react-frameworks*/}
13-
=======
14-
If your app has constraints not well-served by existing frameworks, you prefer to build your own framework, or you just want to learn the basics of a React app, you can [build a React app from scratch](/learn/build-a-react-app-from-scratch).
11+
如果你的应用程序具有现有框架无法很好满足的约束,你更喜欢构建自己的框架,或者你只想学习 React 应用程序的基础知识,你可以 [从头开始构建 React 应用](/learn/build-a-react-app-from-scratch)
1512

16-
## Full-stack frameworks {/*full-stack-frameworks*/}
17-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
13+
## 全栈框架 {/*full-stack-frameworks*/}
1814

1915
这些推荐的框架支持你在生产环境中部署和扩展应用所需的所有功能。它们集成了 React 的最新特性,并充分利用了 React 的架构。
2016

2117
<Note>
2218

23-
<<<<<<< HEAD
24-
#### React 框架不需要服务器。 {/*react-frameworks-do-not-require-a-server*/}
25-
26-
本页面中的所有框架都可以创建单页应用。单页应用可以部署到 [CDN](https://developer.mozilla.org/en-US/docs/Glossary/CDN) 或静态托管服务上,而无需服务器。如果你希望启用需要服务器的功能(例如服务器端渲染),你可以在不重写应用的情况下,为个别路由启用这些功能。
27-
=======
2819
#### Full-stack frameworks do not require a server. {/*react-frameworks-do-not-require-a-server*/}
2920

3021
All the frameworks on this page support client-side rendering ([CSR](https://developer.mozilla.org/en-US/docs/Glossary/CSR)), single-page apps ([SPA](https://developer.mozilla.org/en-US/docs/Glossary/SPA)), and static-site generation ([SSG](https://developer.mozilla.org/en-US/docs/Glossary/SSG)). These apps can be deployed to a [CDN](https://developer.mozilla.org/en-US/docs/Glossary/CDN) or static hosting service without a server. Additionally, these frameworks allow you to add server-side rendering on a per-route basis, when it makes sense for your use case.
3122

3223
This allows you to start with a client-only app, and if your needs change later, you can opt-in to using server features on individual routes without rewriting your app. See your framework's documentation for configuring the rendering strategy.
33-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
3424

3525
</Note>
3626

@@ -69,11 +59,7 @@ npx create-expo-app@latest
6959
Expo 由 [Expo 公司](https://expo.dev/about) 维护。使用 Expo 构建应用是免费的,你可以将应用提交到 Google 和 Apple 应用商店,没有任何限制。Expo 还提供可选的付费云服务。
7060

7161

72-
<<<<<<< HEAD
73-
## 其它选项 {/*other-options*/}
74-
=======
75-
## Other frameworks {/*other-frameworks*/}
76-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
62+
## 其他框架 {/*other-options*/}
7763

7864
还有一些新兴的框架正在努力实现我们的全栈 React 愿景:
7965

@@ -118,23 +104,9 @@ Next.js 的 App Router 还集成了 [使用 Suspense 的数据获取](/blog/2022
118104

119105
If your app has constraints not well-served by existing frameworks, you prefer to build your own framework, or you just want to learn the basics of a React app, there are other options available for starting a React project from scratch.
120106

121-
<<<<<<< HEAD
122-
#### 你推荐使用 Vite 吗? {/*do-you-recommend-vite*/}
123-
124-
我们推荐了一些基于 Vite 的选择。
125-
126-
React Router v7 是一个基于 Vite 的框架,允许你使用 Vite 的快速开发服务器和构建工具,同时提供路由和数据获取功能。与其他推荐的框架一样,你可以用 React Router v7 构建单页应用。
127-
128-
我们也推荐在 [将 React 添加到现有项目中](/learn/add-react-to-an-existing-project),或者 [构建一个 React 框架](/learn/building-a-react-framework) 时使用 Vite。
129-
130-
就像 Svelte 有 Sveltekit、Vue 有 Nuxt、Solid 有 SolidStart 一样,React 推荐使用集成了 Vite 等构建工具的框架来创建新项目。
131-
132-
</Note>
133-
=======
134107
Starting from scratch gives you more flexibility, but does require that you make choices on which tools to use for routing, data fetching, and other common usage patterns. It's a lot like building your own framework, instead of using a framework that already exists. The [frameworks we recommend](#recommended-react-frameworks) have built-in solutions for these problems.
135108

136109
If you want to build your own solutions, see our guide to [build a React app from Scratch](/learn/build-a-react-app-from-scratch) for instructions on how to set up a new React project starting with a built tool like [Vite](https://vite.dev/), [Parcel](https://parceljs.org/), or [RSbuild](https://rsbuild.dev/).
137-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
138110

139111
-----
140112

src/content/learn/installation.md

-14
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,11 @@ React 文档中的大部分页面都包含这样的 sandbox。除 React 文档
4040

4141
## Build a React App from Scratch {/*build-a-react-app-from-scratch*/}
4242

43-
<<<<<<< HEAD
44-
如果某个框架不适合你的项目,或者你更愿意从构建自己的框架开始,则可以 [构建你自己的 React 框架](/learn/building-a-react-framework)
45-
=======
4643
If a framework is not a good fit for your project, you prefer to build your own framework, or you just want to learn the basics of a React app you can [build a React app from scratch](/learn/build-a-react-app-from-scratch).
47-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
4844

4945

5046
## 添加 React 到一个已有的项目 {/*add-react-to-an-existing-project*/}
5147

52-
<<<<<<< HEAD
53-
如果你想尝试在现有应用程序或网站中使用 React,你可以 [将 React 添加到现有项目](/learn/add-react-to-an-existing-project)
54-
55-
## 弃用的选项 {/*deprecated-options*/}
56-
57-
### Create React App(已弃用) {/*create-react-app-deprecated*/}
58-
59-
Create React App 是一个已弃用的工具,以前建议用于创建新的 React 应用。如果你想启动新的 React 应用,你可以 [创建 React 应用](/learn/creating-a-react-app)并使用推荐的框架。
60-
=======
6148

6249
<Note>
6350

@@ -66,7 +53,6 @@ Create React App 是一个已弃用的工具,以前建议用于创建新的 Re
6653
No. Create React App has been deprecated. For more information, see [Sunsetting Create React App](/blog/2025/02/14/sunsetting-create-react-app).
6754

6855
</Note>
69-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
7056

7157
更多信息,参见 [逐步淘汰 Create React App](/blog/2025/02/14/sunsetting-create-react-app)
7258

src/content/learn/render-and-commit.md

+2-19
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,9 @@ export default function Image() {
7676
一旦组件被初次渲染,你就可以通过使用 [`set` 函数](/reference/react/useState#setstate) 更新其状态来触发之后的渲染。更新组件的状态会自动将一次渲染送入队列。(你可以把这种情况想象成餐厅客人在第一次下单之后又点了茶、点心和各种东西,具体取决于他们的胃口。)
7777

7878
<IllustrationBlock sequential>
79-
<<<<<<< HEAD
8079
<Illustration caption="状态更新..." alt="React 作为餐厅服务员将一份 Card UI 送到用户那里,这里的用户以头部为光标的顾客表示。顾客说她想要一个粉色的 Card,而不是黑色的。" src="/images/docs/illustrations/i_rerender1.png" />
8180
<Illustration caption="...触发..." alt="React 回到组件厨房并告诉 Card 主厨他们需要一个粉色 Card。" src="/images/docs/illustrations/i_rerender2.png" />
8281
<Illustration caption="...渲染!" alt="Card 主厨把粉色 Card 交给 React。" src="/images/docs/illustrations/i_rerender3.png" />
83-
=======
84-
<Illustration caption="State update..." alt="React as a server in a restaurant, serving a Card UI to the user, represented as a patron with a cursor for their head. The patron expresses they want a pink card, not a black one!" src="/images/docs/illustrations/i_rerender1.png" />
85-
<Illustration caption="...triggers..." alt="React returns to the Component Kitchen and tells the Card Chef they need a pink Card." src="/images/docs/illustrations/i_rerender2.png" />
86-
<Illustration caption="...render!" alt="The Card Chef gives React the pink Card." src="/images/docs/illustrations/i_rerender3.png" />
87-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
8882
</IllustrationBlock>
8983

9084
## 步骤 2: React 渲染你的组件 {/*step-2-react-renders-your-components*/}
@@ -96,11 +90,7 @@ export default function Image() {
9690

9791
这个过程是递归的:如果更新后的组件会返回某个另外的组件,那么 React 接下来就会渲染 _那个_ 组件,而如果那个组件又返回了某个组件,那么 React 接下来就会渲染 _那个_ 组件,以此类推。这个过程会持续下去,直到没有更多的嵌套组件并且 React 确切知道哪些东西应该显示到屏幕上为止。
9892

99-
<<<<<<< HEAD
10093
在接下来的例子中,React 将会调用 `Gallery()``Image()` 若干次:
101-
=======
102-
In the following example, React will call `Gallery()` and `Image()` several times:
103-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
10494

10595
<Sandpack>
10696

@@ -164,17 +154,10 @@ img { margin: 0 10px 10px 0; }
164154

165155
## 步骤 3: React 把更改提交到 DOM 上 {/*step-3-react-commits-changes-to-the-dom*/}
166156

167-
<<<<<<< HEAD
168157
在渲染(调用)你的组件之后,React 将会修改 DOM。
169158

170-
* **对于初次渲染,** React 会使用 [`appendChild()`](https://developer.mozilla.org/docs/Web/API/Node/appendChild) DOM API 将其创建的所有 DOM 节点放在屏幕上。
171-
* **对于重渲染,** React 将应用最少的必要操作(在渲染时计算!),以使得 DOM 与最新的渲染输出相互匹配。
172-
=======
173-
After rendering (calling) your components, React will modify the DOM.
174-
175-
* **For the initial render,** React will use the [`appendChild()`](https://developer.mozilla.org/docs/Web/API/Node/appendChild) DOM API to put all the DOM nodes it has created on screen.
176-
* **For re-renders,** React will apply the minimal necessary operations (calculated while rendering!) to make the DOM match the latest rendering output.
177-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
159+
* **对于初次渲染**,React 会使用 [`appendChild()`](https://developer.mozilla.org/docs/Web/API/Node/appendChild) DOM API 将其创建的所有 DOM 节点放在屏幕上。
160+
* **对于重渲染**,React 将应用最少的必要操作(在渲染时计算!),以使得 DOM 与最新的渲染输出相互匹配。
178161

179162
**React 仅在渲染之间存在差异时才会更改 DOM 节点。** 例如,有一个组件,它每秒使用从父组件传递下来的不同属性重新渲染一次。注意,你可以添加一些文本到 `<input>` 标签,更新它的 `value`,但是文本不会在组件重渲染时消失:
180163

src/content/learn/state-a-components-memory.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1457,12 +1457,7 @@ export default function FeedbackForm() {
14571457

14581458
#### 移除不必要的 state {/*remove-unnecessary-state*/}
14591459

1460-
<<<<<<< HEAD
1461-
当按钮被点击时,这个例子应该询问用户的名字,然后显示一个 alert 欢迎他们。你尝试使用 state 来保存名字,但由于某种原因,它始终显示“Hello, !”。
1462-
=======
1463-
When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason the first time it shows "Hello, !", and then "Hello, [name]!" with the previous input every time after.
1464-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
1465-
1460+
当按钮被点击时,这个例子应该询问用户的名字,然后显示一个 alert 欢迎他们。你尝试使用 state 来保存名字,但由于某种原因,它显示“Hello, !”,然后是“Hello, [name]!”,每次之后都使用以前的输入。
14661461

14671462
要修复此代码,请删除不必要的 state 变量。(我们将在稍后讨论[为什么上述代码不起作用](/learn/state-as-a-snapshot)。)
14681463

src/content/learn/tutorial-tic-tac-toe.md

-16
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,7 @@ export default function Square() {
295295
}
296296
```
297297

298-
<<<<<<< HEAD
299298
_browser_ 部分应该会像下面这样在方块里面显示一个 X:
300-
=======
301-
The _browser_ section should be displaying a square with an X in it like this:
302-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
303299

304300
![里面是“X”的方块](../images/tutorial/x-filled-square.png)
305301

@@ -1329,11 +1325,7 @@ body {
13291325
1. `handleClick` 使用参数(`0`)将 `squares` 数组的第一个元素从 `null` 更新为 `X`
13301326
1. `Board` 组件的 `squares` state 已更新,因此 `Board` 及其所有子组件都将重新渲染。这会导致索引为 `0``Square` 组件的 `value` props 从 `null` 更改为 `X`
13311327
1332-
<<<<<<< HEAD
13331328
最后,用户看到左上角的方块在单击后从空变为 `X`
1334-
=======
1335-
In the end the user sees that the upper left square has changed from empty to having an `X` after clicking it.
1336-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
13371329
13381330
<Note>
13391331
@@ -1414,11 +1406,7 @@ export default function Board() {
14141406
14151407
`X``O` 覆盖!虽然这会给游戏带来非常有趣的变化,但我们现在将坚持原来的规则。
14161408
1417-
<<<<<<< HEAD
14181409
当你用 `X``O` 标记方块时,你没有检查该方块是否已经具有 `X``O` 值。你可以通过提早返回来解决此问题。我们将检查方块是否已经有 `X``O`。如果方块已经填满,你将尽早在 `handleClick` 函数中 `return`——在它尝试更新棋盘 state 之前。
1419-
=======
1420-
When you mark a square with an `X` or an `O` you aren't first checking to see if the square already has an `X` or `O` value. You can fix this by *returning early*. You'll check to see if the square already has an `X` or an `O`. If the square is already filled, you will `return` in the `handleClick` function early--before it tries to update the board state.
1421-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
14221410
14231411
```js {2,3,4}
14241412
function handleClick(i) {
@@ -1568,11 +1556,7 @@ function calculateWinner(squares) {
15681556
15691557
</Note>
15701558
1571-
<<<<<<< HEAD
15721559
你将在 `Board` 组件的 `handleClick` 函数中调用 `calculateWinner(squares)` 来检查玩家是否获胜。你可以在检查用户是否单击了已经具有 `X``O` 的方块的同时执行此检查。在这两种情况下,我们都希望尽早返回:
1573-
=======
1574-
You will call `calculateWinner(squares)` in the `Board` component's `handleClick` function to check if a player has won. You can perform this check at the same time you check if a user has clicked a square that already has an `X` or an `O`. We'd like to return early in both cases:
1575-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
15761560
15771561
```js {2}
15781562
function handleClick(i) {

src/content/reference/react-dom/components/input.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,7 @@ input { margin: 5px; }
297297

298298
<Pitfall>
299299

300-
<<<<<<< HEAD
301-
默认情况下,`<form>` 内的任何 `<button>` 都可以提交表单。这可能会让人感到惊讶!如果你有自定义 `Button` 组件,请考虑使用 [`<button type="button">`](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/button) 而不是 `<button>`。如果你想要明确指定提交表单的按钮,请使用 `<button type="submit">`
302-
=======
303-
By default, a `<button>` inside a `<form>` without a `type` attribute will submit it. This can be surprising! If you have your own custom `Button` React component, consider using [`<button type="button">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) instead of `<button>` (with no type). Then, to be explicit, use `<button type="submit">` for buttons that *are* supposed to submit the form.
304-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
300+
默认情况下,`<form>` 内的任何没有 `type` 属性的 `<button>` 都可以提交表单。这可能会让人感到惊讶!如果你有自定义 `Button` 组件,请考虑使用 [`<button type="button">`](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/button) 而不是 `<button>`。如果你想要明确指定提交表单的按钮,请使用 `<button type="submit">`
305301

306302
</Pitfall>
307303

src/content/reference/react/useDeferredValue.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,9 @@ function SearchPage() {
8888

8989
这个例子假设你使用了支持 `Suspense` 的数据源:
9090

91-
<<<<<<< HEAD
92-
- 使用支持 suspense 的框架进行数据获取,例如 [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/)[Next.js](https://nextjs.org/docs/getting-started/react-essentials)
91+
- 使用支持 suspense 的框架进行数据获取,例如 [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/)[Next.js](https://nextjs.org/docs/app/getting-started/fetching-data#with-suspenses)
9392
- 使用 [`lazy`](/reference/react/lazy) 懒加载组件代码
9493
- 使用 [`use`](/reference/react/use) 读取 Promise 的值
95-
=======
96-
- Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/app/getting-started/fetching-data#with-suspense)
97-
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
98-
- Reading the value of a Promise with [`use`](/reference/react/use)
99-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
10094

10195
[了解更多有关 suspense 及其限制的信息](/reference/react/Suspense)
10296

src/content/reference/rsc/server-components.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,4 @@ function Comments({commentsPromise}) {
299299

300300
因为 `note` 内容是页面渲染所需的重要数据,所以我们在服务器上进行 `await`。comments 数据在折叠部分中,优先级较低,所以我们在服务器上开始 promise,然后在客户端使用 `use` API 进行等待。这会在客户端上暂停,但不会阻塞 `note` 内容的渲染。
301301

302-
<<<<<<< HEAD
303-
由于异步组件 [在客户端不受支持](#why-cant-i-use-async-components-on-the-client),所以我们通过 `use` 来 await promise。
304-
=======
305-
Since async components are not supported on the client, we await the promise with `use`.
306-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
302+
由于异步组件在客户端不受支持,所以我们通过 `use` 来 await promise。

src/sidebarLearn.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@
2929
"path": "/learn/creating-a-react-app"
3030
},
3131
{
32-
<<<<<<< HEAD
33-
"title": "构建一个 React 框架",
32+
"title": "从头构建一个 React 框架",
3433
"path": "/learn/building-a-react-framework"
35-
=======
36-
"title": "Build a React App from Scratch",
37-
"path": "/learn/build-a-react-app-from-scratch"
38-
>>>>>>> c03f0290502e0b1210f50faaa464489accd57c35
3934
},
4035
{
4136
"title": "将 React 添加到现有项目中",
@@ -44,7 +39,7 @@
4439
]
4540
},
4641
{
47-
"title": "Setup",
42+
"title": "配置",
4843
"path": "/learn/setup",
4944
"routes": [
5045
{

0 commit comments

Comments
 (0)