Skip to content

docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ 50d6991c #1728

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/workflows/analyze_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ on:
types:
- completed

<<<<<<< HEAD
=======
permissions:
contents: read
issues: write
pull-requests: write

>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91
jobs:
comment:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions src/components/Layout/HomeContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ async function Talks({ confId }) {
</CodeBlock>
}
right={
<NavContext.Provider value={{slug, navigate}}>
<NavContext value={{slug, navigate}}>
<BrowserChrome
domain="example.com"
path={'confs/' + slug}
Expand All @@ -1173,7 +1173,7 @@ async function Talks({ confId }) {
</Suspense>
</ExamplePanel>
</BrowserChrome>
</NavContext.Provider>
</NavContext>
}
/>
);
Expand Down
8 changes: 3 additions & 5 deletions src/components/Layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ export function Page({
'max-w-7xl mx-auto',
section === 'blog' && 'lg:flex lg:flex-col lg:items-center'
)}>
<TocContext.Provider value={toc}>
<LanguagesContext.Provider value={languages}>
{children}
</LanguagesContext.Provider>
</TocContext.Provider>
<TocContext value={toc}>
<LanguagesContext value={languages}>{children}</LanguagesContext>
</TocContext>
</div>
{!isBlogIndex && (
<DocsPageFooter
Expand Down
4 changes: 3 additions & 1 deletion src/components/Layout/TopNav/TopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ export default function TopNav({
<BrandMenu>
<div className="flex items-center">
<div className="uwu-visible flex items-center justify-center h-full">
<NextLink href="/">
<NextLink
href="/"
className="active:scale-95 transition-transform">
<Image
alt="logo by @sawaratsuki1004"
title="logo by @sawaratsuki1004"
Expand Down
4 changes: 2 additions & 2 deletions src/components/MDX/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function IllustrationBlock({
</figure>
));
return (
<IllustrationContext.Provider value={isInBlockTrue}>
<IllustrationContext value={isInBlockTrue}>
<div className="relative group before:absolute before:-inset-y-16 before:inset-x-0 my-16 mx-0 2xl:mx-auto max-w-4xl 2xl:max-w-6xl">
{sequential ? (
<ol className="mdx-illustration-block flex">
Expand All @@ -369,7 +369,7 @@ function IllustrationBlock({
)}
<AuthorCredit author={author} authorLink={authorLink} />
</div>
</IllustrationContext.Provider>
</IllustrationContext>
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/content/blog/2024/12/05/react-19.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ function MyInput({placeholder, ref}) {

<Note>

<<<<<<< HEAD
在类组件中,`ref` 不作为 props 传递,因为它们引用的是组件实例。这意味着,如果你在类组件中需要访问 `ref`,你需要使用 `React.forwardRef` 或者 `React.createRef`。
=======
`ref`s passed to classes are not passed as props since they reference the component instance.
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91

</Note>

Expand Down
5 changes: 5 additions & 0 deletions src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ September 2-4, 2025. Wrocław, Poland.

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

### React Alicante 2025 {/*react-alicante-2025*/}
October 2-4, 2025. Alicante, Spain.

[Website](https://reactalicante.es/) - [Twitter](https://x.com/ReactAlicante) - [Bluesky](https://bsky.app/profile/reactalicante.es) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)

### React Conf 2025 {/*react-conf-2025*/}
October 7-8, 2025. Henderson, Nevada, USA and free livestream

Expand Down
1 change: 1 addition & 0 deletions src/content/community/meetups.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
* [Delhi NCR](https://www.meetup.com/React-Delhi-NCR/)
* [Mumbai](https://reactmumbai.dev)
* [Pune](https://www.meetup.com/ReactJS-and-Friends/)
* [Rajasthan](https://reactrajasthan.com)

## Indonesia {/*indonesia*/}
* [Indonesia](https://www.meetup.com/reactindonesia/)
Expand Down
29 changes: 17 additions & 12 deletions src/content/learn/keeping-components-pure.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function Cup({ guest }) {
}

export default function TeaGathering() {
let cups = [];
const cups = [];
for (let i = 1; i <= 12; i++) {
cups.push(<Cup key={i} guest={i} />);
}
Expand Down Expand Up @@ -249,7 +249,7 @@ export default function TeaGathering() {

```js src/Clock.js active
export default function Clock({ time }) {
let hours = time.getHours();
const hours = time.getHours();
if (hours >= 0 && hours <= 6) {
document.getElementById('time').className = 'night';
} else {
Expand Down Expand Up @@ -311,7 +311,7 @@ body > * {

```js src/Clock.js active
export default function Clock({ time }) {
let hours = time.getHours();
const hours = time.getHours();
let className;
if (hours >= 0 && hours <= 6) {
className = 'night';
Expand Down Expand Up @@ -610,14 +610,14 @@ export default function StoryTray({ stories }) {
import { useState, useEffect } from 'react';
import StoryTray from './StoryTray.js';

let initialStories = [
const initialStories = [
{id: 0, label: "Ankit's Story" },
{id: 1, label: "Taylor's Story" },
];

export default function App() {
let [stories, setStories] = useState([...initialStories])
let time = useTime();
const [stories, setStories] = useState([...initialStories])
const time = useTime();

// 临时解决方案:防止在阅读文档时内存无限制增长。
// 我们在这里违反了自己的规则。
Expand Down Expand Up @@ -706,14 +706,14 @@ export default function StoryTray({ stories }) {
import { useState, useEffect } from 'react';
import StoryTray from './StoryTray.js';

let initialStories = [
const initialStories = [
{id: 0, label: "Ankit's Story" },
{id: 1, label: "Taylor's Story" },
];

export default function App() {
let [stories, setStories] = useState([...initialStories])
let time = useTime();
const [stories, setStories] = useState([...initialStories])
const time = useTime();

// 临时解决方案:防止在阅读文档时内存无限制增长。
// 我们在这里违反了自己的规则。
Expand Down Expand Up @@ -773,8 +773,13 @@ li {

```js src/StoryTray.js active
export default function StoryTray({ stories }) {
<<<<<<< HEAD
// 复制数组!
let storiesToDisplay = stories.slice();
=======
// Copy the array!
const storiesToDisplay = stories.slice();
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91

// 不影响原始数组:
storiesToDisplay.push({
Expand All @@ -798,14 +803,14 @@ export default function StoryTray({ stories }) {
import { useState, useEffect } from 'react';
import StoryTray from './StoryTray.js';

let initialStories = [
const initialStories = [
{id: 0, label: "Ankit's Story" },
{id: 1, label: "Taylor's Story" },
];

export default function App() {
let [stories, setStories] = useState([...initialStories])
let time = useTime();
const [stories, setStories] = useState([...initialStories])
const time = useTime();

// 临时解决方案:防止在阅读文档时内存无限制增长。
// 我们在这里违反了自己的规则。
Expand Down
14 changes: 6 additions & 8 deletions src/content/learn/managing-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,9 @@ export default function Section({ children }) {
const level = useContext(LevelContext);
return (
<section className="section">
<LevelContext.Provider value={level + 1}>
<LevelContext value={level + 1}>
{children}
</LevelContext.Provider>
</LevelContext>
</section>
);
}
Expand Down Expand Up @@ -839,13 +839,11 @@ export function TasksProvider({ children }) {
);

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider
value={dispatch}
>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
{children}
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down
4 changes: 4 additions & 0 deletions src/content/learn/preserving-and-resetting-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,11 @@ label {

</Sandpack>

<<<<<<< HEAD
当你勾选复选框后计数器的 state 被重置了。虽然你渲染了一个 `Counter`,但是 `div` 的第一个子组件从 `div` 变成了 `section`。当子组件 `div` 从 DOM 中被移除的时候,它底下的整棵树(包含 `Counter` 以及它的 state)也都被销毁了。
=======
The counter state gets reset when you click the checkbox. Although you render a `Counter`, the first child of the `div` changes from a `section` to a `div`. When the child `section` was removed from the DOM, the whole tree below it (including the `Counter` and its state) was destroyed as well.
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91

<DiagramGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/content/learn/referencing-values-with-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ export default function Toggle() {

#### 修复防抖 {/*fix-debouncing*/}

<<<<<<< HEAD
在这个例子中,所有按钮点击处理器都是 ["防抖的"](https://redd.one/blog/debounce-vs-throttle)。 要了解这意味着什么,请按下其中一个按钮。注意消息在一秒后显示。如果你在等待消息时按下按钮,计时器将重置。因此如果你多次快速单击同一个按钮,则直到你停止单击 **之后** 1 秒钟,该消息才会显示。防抖可以让你将一些动作推迟到用户“停止动作”之后。
=======
In this example, all button click handlers are ["debounced".](https://kettanaito.com/blog/debounce-vs-throttle) To see what this means, press one of the buttons. Notice how the message appears a second later. If you press the button while waiting for the message, the timer will reset. So if you keep clicking the same button fast many times, the message won't appear until a second *after* you stop clicking. Debouncing lets you delay some action until the user "stops doing things".
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91

这个例子可以正常运行,但并不完全符合预期。按钮不是独立的。要查看问题,请单击其中一个按钮,然后立即单击另一个按钮。你本来期望在延迟之后,你会看到两个按钮的消息。但只有最后一个按钮的消息出现了。第一个按钮的消息丢失了。

Expand Down
57 changes: 28 additions & 29 deletions src/content/learn/scaling-up-with-reducer-and-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@ export default function TaskApp() {
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks);
// ...
return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
...
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}
```
Expand Down Expand Up @@ -514,8 +514,8 @@ export default function TaskApp() {
}

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
<h1>Day off in Kyoto</h1>
<AddTask
onAddTask={handleAddTask}
Expand All @@ -525,8 +525,8 @@ export default function TaskApp() {
onChangeTask={handleChangeTask}
onDeleteTask={handleDeleteTask}
/>
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down Expand Up @@ -681,13 +681,13 @@ ul, li { margin: 0; padding: 0; }
现在你不需要将 tasks 和事件处理程序在组件树中传递:

```js {4-5}
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
<h1>Day off in Kyoto</h1>
<AddTask />
<TaskList />
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
```

相反,任何需要 tasks 的组件都可以从 `TaskContext` 中读取它:
Expand Down Expand Up @@ -735,13 +735,13 @@ export default function TaskApp() {
);

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
<h1>Day off in Kyoto</h1>
<AddTask />
<TaskList />
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down Expand Up @@ -926,11 +926,11 @@ export function TasksProvider({ children }) {
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks);

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
{children}
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}
```
Expand Down Expand Up @@ -968,11 +968,11 @@ export function TasksProvider({ children }) {
);

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
{children}
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down Expand Up @@ -1179,11 +1179,11 @@ export function TasksProvider({ children }) {
);

return (
<TasksContext.Provider value={tasks}>
<TasksDispatchContext.Provider value={dispatch}>
<TasksContext value={tasks}>
<TasksDispatchContext value={dispatch}>
{children}
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down Expand Up @@ -1368,4 +1368,3 @@ ul, li { margin: 0; padding: 0; }
- 你可以在你的应用程序中大量使用 context 和 reducer 的组合。

</Recap>

Loading