Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ e2bba41b #1639

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9fb491d
Fix troubleshooting links in startTransition reference (#7367)
jimmycallin Dec 16, 2024
51864f6
(fix): mismatch href bug (#7368)
ahm3tozenir Dec 16, 2024
bc93f05
Fix stylesheet precedence example (#7235)
EricCote Dec 16, 2024
07eca83
Fix intro of prerenderToNodeStream (#7356)
smikitky Dec 16, 2024
c92bad2
chore: several major typo fixes (#7362)
coalio Dec 16, 2024
d3bd0f9
Update act.md (#7363)
huiliangShen Dec 16, 2024
31456db
chore: correct typo in useTransition docs (#7366)
AminDannak Dec 16, 2024
d4d1683
chore: fix a typo in startTransition docs (#7361)
AminDannak Dec 16, 2024
04ba43c
fix: add link to prop-type codemod (#7344)
renbaoshuo Dec 16, 2024
4349dd5
fix: anchor (#7343)
Jealh-h Dec 16, 2024
d3cde8f
Fix "won't break between majors" (#7357)
smikitky Dec 16, 2024
37e1ce9
Add React Summit 2025 to conferences.md; move past conferences to the…
McFrid Dec 16, 2024
4b5ce91
Add missing react-error-boundary dependency (#7353)
acusti Dec 16, 2024
0805613
fix broken link in use server (#7351)
simon300000 Dec 16, 2024
a4b6074
fix: page does not exist (#7348)
nusr Dec 16, 2024
807e7fa
Mention that uncontrolled form elements are reset by form actions (#7…
jeremy-deutsch Dec 16, 2024
0f8bd80
Code example mistake in useMemo page (#7335)
JZZICK Dec 16, 2024
3558095
docs: include React 19 blog post in sidebarBlog.json (#7331)
slorber Dec 16, 2024
93a03f1
docs: Fix broken link to next.js Suspense docs (#7318)
ethshea Dec 16, 2024
204b3f1
Remove canary flag from useFormStatus (#7349)
smikitky Dec 16, 2024
8ac5531
Rename remaining "Server Actions" (#7352)
smikitky Dec 16, 2024
9985199
docs[compiler]: clarify React DevTools support for Compiler Badges in…
piotrski Dec 16, 2024
c37fdd3
Remove forwardref from useImperativeHandle docs (#7360)
SebassNoob Dec 16, 2024
e2bba41
docs: fix readme node version (#7316)
devwqc Dec 16, 2024
017dcb0
docs(en): merging all conflicts
docschina-bot Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This repo contains the source code and documentation powering [react.dev](https:
### Prerequisites

1. Git
1. Node: any 12.x version starting with v12.0.0 or greater
1. Node: any version starting with v16.8.0 or greater
1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/)
1. A fork of the repo (for any contributions)
1. A clone of the [react.dev repo](https://github.com/reactjs/react.dev) on your local machine
Expand Down
2 changes: 1 addition & 1 deletion src/content/blog/2024/04/25/react-19-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ This will run the following codemods from `react-codemod`:
- [`replace-string-ref`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-string-ref)
- [`replace-act-import`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-act-import)
- [`replace-use-form-state`](https://github.com/reactjs/react-codemod?tab=readme-ov-file#replace-use-form-state)
- [`prop-types-typescript`](TODO)
- [`prop-types-typescript`](https://codemod.com/registry/react-prop-types-typescript)

This does not include the TypeScript changes. See [TypeScript changes](#typescript-changes) below.

Expand Down
12 changes: 12 additions & 0 deletions src/content/blog/2024/12/05/react-19.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ description: React 19 版现在可以在 npm 上使用了! 在这篇文章中,
- **预热 suspend 树**:阅读 [改善 Suspense](/blog/2024/04/25/react-19-upgrade-guide#improvements-to-suspense) 来了解更多。
- **React DOM 静态 API**:阅读 [新的 React DOM 静态 API](#new-react-dom-static-apis) 来了解更多。

<<<<<<< HEAD
__本文的日期已更新,以反映稳定版的发布日期。__
=======
_The date for this post has been updated to reflect the stable release date._
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

</Note>

Expand Down Expand Up @@ -362,7 +366,11 @@ React 19 包含了所有从 Canary 渠道引入的 React 服务器组件功能

#### 如何构建对服务器组件的支持? {/*how-do-i-build-support-for-server-components*/}

<<<<<<< HEAD
虽然 React 19 中的 React 服务器组件是稳定的,并且在主版本之间不会发生破坏,但用于实现 React 服务器组件打包器或框架的底层 API 不遵循 semver,并可能在 React 19.x 的小版本之间发生破坏。
=======
While React Server Components in React 19 are stable and will not break between minor versions, the underlying APIs used to implement a React Server Components bundler or framework do not follow semver and may break between minors in React 19.x.
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

为了支持 React 服务器组件作为打包器或框架,我们建议固定到特定的 React 版本,或者使用 Canary 发行版。我们将继续与打包器和框架合作,以稳定用于实现 React 服务器组件的 API。

Expand Down Expand Up @@ -807,4 +815,8 @@ React 19 添加了对自定义元素的全面支持,并通过了 [Custom Eleme

请查看 [React 19 升级指南](/blog/2024/04/25/react-19-upgrade-guide) 以获取逐步指导和完整的破坏性和显著变化列表。

<<<<<<< HEAD
__注意:这篇文章最初发布于 2024 年 4 月 25 日,并已将内容更新至 2024 年 12 月 5 日发布的稳定版本。__
=======
_Note: this post was originally published 04/25/2024 and has been updated to 12/05/2024 with the stable release._
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66
68 changes: 37 additions & 31 deletions src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,68 @@ Do you know of a local React.js conference? Add it here! (Please keep the list c

## Upcoming Conferences {/*upcoming-conferences*/}

### React Universe Conf 2024 {/*react-universe-conf-2024*/}
September 5-6, 2024. Wrocław, Poland.
### React Day Berlin 2024 {/*react-day-berlin-2024*/}
December 13 & 16, 2024. In-person in Berlin, Germany + remote (hybrid event)

[Website](https://www.reactuniverseconf.com/) - [Twitter](https://twitter.com/react_native_eu) - [LinkedIn](https://www.linkedin.com/events/reactuniverseconf7163919537074118657/)
[Website](https://reactday.berlin/) - [Twitter](https://x.com/reactdayberlin)

### React Alicante 2024 {/*react-alicante-2024*/}
September 19-21, 2024. Alicante, Spain.
### React Summit 2025 {/*react-summit-2025*/}
June 13 - 17, 2025. In-person in Amsterdam, Netherlands + remote (hybrid event)

[Website](https://reactalicante.es/) - [Twitter](https://twitter.com/ReactAlicante) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)
[Website](https://reactsummit.com/) - [Twitter](https://x.com/reactsummit)

### RenderCon Kenya 2024 {/*rendercon-kenya-2024*/}
October 04 - 05, 2024. Nairobi, Kenya
## Past Conferences {/*past-conferences*/}

[Website](https://rendercon.org/) - [Twitter](https://twitter.com/renderconke) - [LinkedIn](https://www.linkedin.com/company/renderconke/) - [YouTube](https://www.youtube.com/channel/UC0bCcG8gHUL4njDOpQGcMIA)
### React Africa 2024 {/*react-africa-2024*/}
November 29, 2024. In-person in Casablanca, Morocco (hybrid event)

### React India 2024 {/*react-india-2024*/}
October 17 - 19, 2024. In-person in Goa, India (hybrid event) + Oct 15 2024 - remote day
[Website](https://react-africa.com/) - [Twitter](https://x.com/BeJS_)

[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia) - [Youtube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w)
### React Summit US 2024 {/*react-summit-us-2024*/}
November 19 & 22, 2024. In-person in New York, USA + online (hybrid event)

### React Brussels 2024 {/*react-brussels-2024*/}
October 18, 2024. In-person in Brussels, Belgium (hybrid event)
[Website](https://reactsummit.us/) - [Twitter](https://twitter.com/reactsummit) - [Videos](https://portal.gitnation.org/)

[Website](https://www.react.brussels/) - [Twitter](https://x.com/BrusselsReact)
### React Native London Conf 2024 {/*react-native-london-2024*/}
November 14 & 15, 2024. In-person in London, UK

[Website](https://reactnativelondon.co.uk/) - [Twitter](https://x.com/RNLConf)

### React Advanced London 2024 {/*react-advanced-london-2024*/}
October 25 & 28, 2024. In-person in London, UK + online (hybrid event)

[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced)

### reactjsday 2024 {/*reactjsday-2024*/}
October 25, 2024. In-person in Verona, Italy + online (hybrid event)

[Website](https://2024.reactjsday.it/) - [Twitter](https://x.com/reactjsday) - [Facebook](https://www.facebook.com/GrUSP/) - [YouTube](https://www.youtube.com/c/grusp)

### React Advanced London 2024 {/*react-advanced-london-2024*/}
October 25 & 28, 2024. In-person in London, UK + online (hybrid event)
### React Brussels 2024 {/*react-brussels-2024*/}
October 18, 2024. In-person in Brussels, Belgium (hybrid event)

[Website](https://reactadvanced.com/) - [Twitter](https://x.com/reactadvanced)
[Website](https://www.react.brussels/) - [Twitter](https://x.com/BrusselsReact)

### React Native London Conf 2024 {/*react-native-london-2024*/}
November 14 & 15, 2024. In-person in London, UK
### React India 2024 {/*react-india-2024*/}
October 17 - 19, 2024. In-person in Goa, India (hybrid event) + Oct 15 2024 - remote day

[Website](https://reactnativelondon.co.uk/) - [Twitter](https://x.com/RNLConf)
[Website](https://www.reactindia.io) - [Twitter](https://twitter.com/react_india) - [Facebook](https://www.facebook.com/ReactJSIndia) - [Youtube](https://www.youtube.com/channel/UCaFbHCBkPvVv1bWs_jwYt3w)

### React Summit US 2024 {/*react-summit-us-2024*/}
November 19 & 22, 2024. In-person in New York, USA + online (hybrid event)
### RenderCon Kenya 2024 {/*rendercon-kenya-2024*/}
October 04 - 05, 2024. Nairobi, Kenya

[Website](https://reactsummit.us/) - [Twitter](https://twitter.com/reactsummit) - [Videos](https://portal.gitnation.org/)
[Website](https://rendercon.org/) - [Twitter](https://twitter.com/renderconke) - [LinkedIn](https://www.linkedin.com/company/renderconke/) - [YouTube](https://www.youtube.com/channel/UC0bCcG8gHUL4njDOpQGcMIA)

### React Africa 2024 {/*react-africa-2024*/}
November 29, 2024. In-person in Casablanca, Morocco (hybrid event)
### React Alicante 2024 {/*react-alicante-2024*/}
September 19-21, 2024. Alicante, Spain.

[Website](https://react-africa.com/) - [Twitter](https://x.com/BeJS_)
[Website](https://reactalicante.es/) - [Twitter](https://twitter.com/ReactAlicante) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)

### React Day Berlin 2024 {/*react-day-berlin-2024*/}
December 13 & 16, 2024. In-person in Berlin, Germany + remote (hybrid event)
### React Universe Conf 2024 {/*react-universe-conf-2024*/}
September 5-6, 2024. Wrocław, Poland.

[Website](https://reactday.berlin/) - [Twitter](https://x.com/reactdayberlin)
[Website](https://www.reactuniverseconf.com/) - [Twitter](https://twitter.com/react_native_eu) - [LinkedIn](https://www.linkedin.com/events/reactuniverseconf7163919537074118657/)

## Past Conferences {/*past-conferences*/}

### React Rally 2024 🐙 {/*react-rally-2024*/}
August 12-13, 2024. Park City, UT, USA
Expand Down
4 changes: 4 additions & 0 deletions src/content/learn/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ translators:

<Intro>

<<<<<<< HEAD
欢迎来到 React 文档!本章节将介绍你每天都会使用的 80% 的 React 概念。
=======
Welcome to the React documentation! This page will give you an introduction to 80% of the React concepts that you will use on a daily basis.
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

</Intro>

Expand Down
4 changes: 4 additions & 0 deletions src/content/learn/react-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ React Compiler 可以静态验证 React 的许多规则,并且在检测到错

### 我如何知道我的组件已被优化? {/*how-do-i-know-my-components-have-been-optimized*/}

<<<<<<< HEAD
[React 开发工具](/learn/react-developer-tools)(v5.0 及以上版本)对 React Compiler 有内置支持,并会在已被编译器优化的组件旁边显示“Memo ✨”徽章。
=======
[React DevTools](/learn/react-developer-tools) (v5.0+) and [React Native DevTools](https://reactnative.dev/docs/react-native-devtools) have built-in support for React Compiler and will display a "Memo ✨" badge next to components that have been optimized by the compiler.
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

### 编译后某些内容无法正常工作 {/*something-is-not-working-after-compilation*/}
如果你安装了 eslint-plugin-react-compiler ,编译器将在你的编辑器中显示任何违反 React 规则的情况。当它这样做时,意味着编译器跳过了对该组件或钩子的优化。这完全没问题,并且编译器可以恢复并继续优化你代码库中的其他组件。**你不必立即修复所有的违反 ESLint 规则的代码。** 你可以按照自己的节奏来处理它们,以增加被优化的组件和钩子的数量。
Expand Down
4 changes: 2 additions & 2 deletions src/content/reference/react-dom/components/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ To create interactive controls for submitting information, render the [built-in

### Handle form submission on the client {/*handle-form-submission-on-the-client*/}

Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs.
Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs. After the `action` function succeeds, all uncontrolled field elements in the form are reset.

<Sandpack>

Expand Down Expand Up @@ -117,7 +117,7 @@ function AddToCart({productId}) {
}
```

When `<form>` is rendered by a [Server Component](/reference/rsc/use-client), and a [Server Function](/reference/rsc/server-function) is passed to the `<form>`'s `action` prop, the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
When `<form>` is rendered by a [Server Component](/reference/rsc/use-client), and a [Server Function](/reference/rsc/server-functions) is passed to the `<form>`'s `action` prop, the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).

### Display a pending state during form submission {/*display-a-pending-state-during-form-submission*/}
To display a pending state when a form is being submitted, you can call the `useFormStatus` Hook in a component rendered in a `<form>` and read the `pending` property returned.
Expand Down
19 changes: 17 additions & 2 deletions src/content/reference/react-dom/components/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ export default function SiteMapPage() {

### 控制样式表优先级 {/*controlling-stylesheet-precedence*/}

<<<<<<< HEAD
样式表可能会相互冲突,当发生冲突时,浏览器会选择文档中排在后面的样式表。React 允许使用 `precedence` 属性来控制样式表的顺序。在这个例子中,两个组件渲染样式表,具有较高优先级的组件在文档中排在较后位置,即使渲染它的组件出现在较早位置。

{/*FIXME: this doesn't appear to actually work -- I guess precedence isn't implemented yet?*/}
=======
Stylesheets can conflict with each other, and when they do, the browser goes with the one that comes later in the document. React lets you control the order of stylesheets with the `precedence` prop. In this example, three components render stylesheets, and the ones with the same precedence are grouped together in the `<head>`.
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

<SandpackWithHTMLOutput>

Expand All @@ -165,24 +169,35 @@ export default function HomePage() {
<ShowRenderedHTML>
<FirstComponent />
<SecondComponent />
<ThirdComponent/>
...
</ShowRenderedHTML>
);
}

function FirstComponent() {
return <link rel="stylesheet" href="first.css" precedence="high" />;
return <link rel="stylesheet" href="first.css" precedence="first" />;
}

function SecondComponent() {
return <link rel="stylesheet" href="second.css" precedence="low" />;
return <link rel="stylesheet" href="second.css" precedence="second" />;
}

function ThirdComponent() {
return <link rel="stylesheet" href="third.css" precedence="first" />;
}

```

</SandpackWithHTMLOutput>

<<<<<<< HEAD
### 去除样式表的重复渲染 {/*deduplicated-stylesheet-rendering*/}
=======
Note the `precedence` values themselves are arbitrary and their naming is up to you. React will infer that precedence values it discovers first are "lower" and precedence values it discovers later are "higher".

### Deduplicated stylesheet rendering {/*deduplicated-stylesheet-rendering*/}
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

如果在多个组件渲染相同的样式表,React 将只在文档头部放置单个 `<link>`。

Expand Down
1 change: 0 additions & 1 deletion src/content/reference/react-dom/hooks/useFormStatus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: useFormStatus
canary: true
---

<Intro>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: prerenderToNodeStream

<Intro>

`prerender` renders a React tree to a static HTML string using a [Node.js Stream.](https://nodejs.org/api/stream.html).
`prerenderToNodeStream` renders a React tree to a static HTML string using a [Node.js Stream.](https://nodejs.org/api/stream.html).

```js
const {prelude} = await prerenderToNodeStream(reactNode, options?)
Expand Down Expand Up @@ -292,4 +292,4 @@ Suspense-enabled data fetching without the use of an opinionated framework is no
The `prerenderToNodeStream` response waits for the entire app to finish rendering, including waiting for all suspense boundaries to resolve, before resolving. It is designed for static site generation (SSG) ahead of time and does not support streaming more content as it loads.

To stream content as it loads, use a streaming server render API like [renderToPipeableStream](/reference/react-dom/server/renderToPipeableStream).


6 changes: 6 additions & 0 deletions src/content/reference/react/Suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,15 @@ async function getAlbums() {

**只有启用了 Suspense 的数据源才会激活 Suspense 组件**,它们包括:

<<<<<<< HEAD
- 支持 Suspense 的框架如 [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) 和 [Next.js](https://nextjs.org/docs/getting-started/react-essentials)。
- 使用 [`lazy`](/reference/react/lazy) 懒加载组件代码。
- 使用 [`use`](/reference/react/use) 读取缓存的 Promise 值。
=======
- 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/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense)
- Lazy-loading component code with [`lazy`](/reference/react/lazy)
- Reading the value of a cached Promise with [`use`](/reference/react/use)
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

Suspense **无法** 检测在 Effect 或事件处理程序中获取数据的情况。

Expand Down
6 changes: 3 additions & 3 deletions src/content/reference/react/act.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ function Counter() {
}

useEffect(() => {
document.title = `You clicked ${this.state.count} times`;
document.title = `You clicked ${count} times`;
}, [count]);

return (
<div>
<p>You clicked {this.state.count} times</p>
<button onClick={this.handleClick}>
<p>You clicked {count} times</p>
<button onClick={handleClick}>
Click me
</button>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/content/reference/react/createContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ function Button() {
}
```

<<<<<<< HEAD
尽管这种老方法依然奏效,但 **新代码都应该通过 [`useContext()`](/reference/react/useContext) 来读取上下文**:
=======
Although this older way still works, **newly written code should read context with [`useContext()`](/reference/react/useContext) instead:**
>>>>>>> e2bba41bf0f4913b7faaeff4920ec4eb98207a66

```js
function Button() {
Expand Down
Loading
Loading