Skip to content

Commit 749d8de

Browse files
authored
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ 50d6991 (#1728)
2 parents 471033d + 981c9cf commit 749d8de

27 files changed

+174
-155
lines changed

.github/workflows/analyze_comment.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
issues: write
12+
pull-requests: write
13+
914
jobs:
1015
comment:
1116
runs-on: ubuntu-latest

src/components/Layout/HomeContent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ async function Talks({ confId }) {
11531153
</CodeBlock>
11541154
}
11551155
right={
1156-
<NavContext.Provider value={{slug, navigate}}>
1156+
<NavContext value={{slug, navigate}}>
11571157
<BrowserChrome
11581158
domain="example.com"
11591159
path={'confs/' + slug}
@@ -1173,7 +1173,7 @@ async function Talks({ confId }) {
11731173
</Suspense>
11741174
</ExamplePanel>
11751175
</BrowserChrome>
1176-
</NavContext.Provider>
1176+
</NavContext>
11771177
}
11781178
/>
11791179
);

src/components/Layout/Page.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ export function Page({
8282
'max-w-7xl mx-auto',
8383
section === 'blog' && 'lg:flex lg:flex-col lg:items-center'
8484
)}>
85-
<TocContext.Provider value={toc}>
86-
<LanguagesContext.Provider value={languages}>
87-
{children}
88-
</LanguagesContext.Provider>
89-
</TocContext.Provider>
85+
<TocContext value={toc}>
86+
<LanguagesContext value={languages}>{children}</LanguagesContext>
87+
</TocContext>
9088
</div>
9189
{!isBlogIndex && (
9290
<DocsPageFooter

src/components/Layout/TopNav/TopNav.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ export default function TopNav({
266266
<BrandMenu>
267267
<div className="flex items-center">
268268
<div className="uwu-visible flex items-center justify-center h-full">
269-
<NextLink href="/">
269+
<NextLink
270+
href="/"
271+
className="active:scale-95 transition-transform">
270272
<Image
271273
alt="logo by @sawaratsuki1004"
272274
title="logo by @sawaratsuki1004"

src/components/MDX/MDXComponents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function IllustrationBlock({
354354
</figure>
355355
));
356356
return (
357-
<IllustrationContext.Provider value={isInBlockTrue}>
357+
<IllustrationContext value={isInBlockTrue}>
358358
<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">
359359
{sequential ? (
360360
<ol className="mdx-illustration-block flex">
@@ -369,7 +369,7 @@ function IllustrationBlock({
369369
)}
370370
<AuthorCredit author={author} authorLink={authorLink} />
371371
</div>
372-
</IllustrationContext.Provider>
372+
</IllustrationContext>
373373
);
374374
}
375375

src/content/blog/2024/12/05/react-19.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ function MyInput({placeholder, ref}) {
410410

411411
<Note>
412412

413-
在类组件中,`ref` 不作为 props 传递,因为它们引用的是组件实例。这意味着,如果你在类组件中需要访问 `ref`,你需要使用 `React.forwardRef` 或者 `React.createRef`
413+
在类组件中,`ref` 不作为 props 传递,因为它们引用的是组件实例。
414414

415415
</Note>
416416

src/content/community/conferences.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ September 2-4, 2025. Wrocław, Poland.
4545

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

48+
### React Alicante 2025 {/*react-alicante-2025*/}
49+
October 2-4, 2025. Alicante, Spain.
50+
51+
[Website](https://reactalicante.es/) - [Twitter](https://x.com/ReactAlicante) - [Bluesky](https://bsky.app/profile/reactalicante.es) - [YouTube](https://www.youtube.com/channel/UCaSdUaITU1Cz6PvC97A7e0w)
52+
4853
### React Conf 2025 {/*react-conf-2025*/}
4954
October 7-8, 2025. Henderson, Nevada, USA and free livestream
5055

src/content/community/meetups.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
8888
* [Delhi NCR](https://www.meetup.com/React-Delhi-NCR/)
8989
* [Mumbai](https://reactmumbai.dev)
9090
* [Pune](https://www.meetup.com/ReactJS-and-Friends/)
91+
* [Rajasthan](https://reactrajasthan.com)
9192

9293
## Indonesia {/*indonesia*/}
9394
* [Indonesia](https://www.meetup.com/reactindonesia/)

src/content/learn/keeping-components-pure.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function Cup({ guest }) {
179179
}
180180

181181
export default function TeaGathering() {
182-
let cups = [];
182+
const cups = [];
183183
for (let i = 1; i <= 12; i++) {
184184
cups.push(<Cup key={i} guest={i} />);
185185
}
@@ -249,7 +249,7 @@ export default function TeaGathering() {
249249

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

312312
```js src/Clock.js active
313313
export default function Clock({ time }) {
314-
let hours = time.getHours();
314+
const hours = time.getHours();
315315
let className;
316316
if (hours >= 0 && hours <= 6) {
317317
className = 'night';
@@ -610,14 +610,14 @@ export default function StoryTray({ stories }) {
610610
import { useState, useEffect } from 'react';
611611
import StoryTray from './StoryTray.js';
612612

613-
let initialStories = [
613+
const initialStories = [
614614
{id: 0, label: "Ankit's Story" },
615615
{id: 1, label: "Taylor's Story" },
616616
];
617617

618618
export default function App() {
619-
let [stories, setStories] = useState([...initialStories])
620-
let time = useTime();
619+
const [stories, setStories] = useState([...initialStories])
620+
const time = useTime();
621621

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

709-
let initialStories = [
709+
const initialStories = [
710710
{id: 0, label: "Ankit's Story" },
711711
{id: 1, label: "Taylor's Story" },
712712
];
713713

714714
export default function App() {
715-
let [stories, setStories] = useState([...initialStories])
716-
let time = useTime();
715+
const [stories, setStories] = useState([...initialStories])
716+
const time = useTime();
717717

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

774774
```js src/StoryTray.js active
775775
export default function StoryTray({ stories }) {
776+
<<<<<<< HEAD
776777
// 复制数组!
777778
let storiesToDisplay = stories.slice();
779+
=======
780+
// Copy the array!
781+
const storiesToDisplay = stories.slice();
782+
>>>>>>> 50d6991ca6652f4bc4c985cf0c0e593864f2cc91
778783

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

801-
let initialStories = [
806+
const initialStories = [
802807
{id: 0, label: "Ankit's Story" },
803808
{id: 1, label: "Taylor's Story" },
804809
];
805810

806811
export default function App() {
807-
let [stories, setStories] = useState([...initialStories])
808-
let time = useTime();
812+
const [stories, setStories] = useState([...initialStories])
813+
const time = useTime();
809814

810815
// 临时解决方案:防止在阅读文档时内存无限制增长。
811816
// 我们在这里违反了自己的规则。

src/content/learn/managing-state.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,9 @@ export default function Section({ children }) {
744744
const level = useContext(LevelContext);
745745
return (
746746
<section className="section">
747-
<LevelContext.Provider value={level + 1}>
747+
<LevelContext value={level + 1}>
748748
{children}
749-
</LevelContext.Provider>
749+
</LevelContext>
750750
</section>
751751
);
752752
}
@@ -839,13 +839,11 @@ export function TasksProvider({ children }) {
839839
);
840840

841841
return (
842-
<TasksContext.Provider value={tasks}>
843-
<TasksDispatchContext.Provider
844-
value={dispatch}
845-
>
842+
<TasksContext value={tasks}>
843+
<TasksDispatchContext value={dispatch}>
846844
{children}
847-
</TasksDispatchContext.Provider>
848-
</TasksContext.Provider>
845+
</TasksDispatchContext>
846+
</TasksContext>
849847
);
850848
}
851849

src/content/learn/preserving-and-resetting-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ label {
676676

677677
</Sandpack>
678678

679-
当你勾选复选框后计数器的 state 被重置了。虽然你渲染了一个 `Counter`,但是 `div` 的第一个子组件从 `div` 变成了 `section`。当子组件 `div` 从 DOM 中被移除的时候,它底下的整棵树(包含 `Counter` 以及它的 state)也都被销毁了。
679+
当你勾选复选框后计数器的 state 被重置了。虽然你渲染了一个 `Counter`,但是 `div` 的第一个子组件从 `section` 变成了 `div`。当子组件 `section` 从 DOM 中被移除的时候,它底下的整棵树(包含 `Counter` 以及它的 state)也都被销毁了。
680680

681681
<DiagramGroup>
682682

src/content/learn/referencing-values-with-refs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export default function Toggle() {
467467

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

470-
在这个例子中,所有按钮点击处理器都是 ["防抖的"](https://redd.one/blog/debounce-vs-throttle)。 要了解这意味着什么,请按下其中一个按钮。注意消息在一秒后显示。如果你在等待消息时按下按钮,计时器将重置。因此如果你多次快速单击同一个按钮,则直到你停止单击 **之后** 1 秒钟,该消息才会显示。防抖可以让你将一些动作推迟到用户“停止动作”之后。
470+
在这个例子中,所有按钮点击处理器都是 ["防抖的"](https://kettanaito.com/blog/debounce-vs-throttle)。 要了解这意味着什么,请按下其中一个按钮。注意消息在一秒后显示。如果你在等待消息时按下按钮,计时器将重置。因此如果你多次快速单击同一个按钮,则直到你停止单击 **之后** 1 秒钟,该消息才会显示。防抖可以让你将一些动作推迟到用户“停止动作”之后。
471471

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

src/content/learn/scaling-up-with-reducer-and-context.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ export default function TaskApp() {
466466
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks);
467467
// ...
468468
return (
469-
<TasksContext.Provider value={tasks}>
470-
<TasksDispatchContext.Provider value={dispatch}>
469+
<TasksContext value={tasks}>
470+
<TasksDispatchContext value={dispatch}>
471471
...
472-
</TasksDispatchContext.Provider>
473-
</TasksContext.Provider>
472+
</TasksDispatchContext>
473+
</TasksContext>
474474
);
475475
}
476476
```
@@ -514,8 +514,8 @@ export default function TaskApp() {
514514
}
515515

516516
return (
517-
<TasksContext.Provider value={tasks}>
518-
<TasksDispatchContext.Provider value={dispatch}>
517+
<TasksContext value={tasks}>
518+
<TasksDispatchContext value={dispatch}>
519519
<h1>Day off in Kyoto</h1>
520520
<AddTask
521521
onAddTask={handleAddTask}
@@ -525,8 +525,8 @@ export default function TaskApp() {
525525
onChangeTask={handleChangeTask}
526526
onDeleteTask={handleDeleteTask}
527527
/>
528-
</TasksDispatchContext.Provider>
529-
</TasksContext.Provider>
528+
</TasksDispatchContext>
529+
</TasksContext>
530530
);
531531
}
532532

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

683683
```js {4-5}
684-
<TasksContext.Provider value={tasks}>
685-
<TasksDispatchContext.Provider value={dispatch}>
684+
<TasksContext value={tasks}>
685+
<TasksDispatchContext value={dispatch}>
686686
<h1>Day off in Kyoto</h1>
687687
<AddTask />
688688
<TaskList />
689-
</TasksDispatchContext.Provider>
690-
</TasksContext.Provider>
689+
</TasksDispatchContext>
690+
</TasksContext>
691691
```
692692

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

737737
return (
738-
<TasksContext.Provider value={tasks}>
739-
<TasksDispatchContext.Provider value={dispatch}>
738+
<TasksContext value={tasks}>
739+
<TasksDispatchContext value={dispatch}>
740740
<h1>Day off in Kyoto</h1>
741741
<AddTask />
742742
<TaskList />
743-
</TasksDispatchContext.Provider>
744-
</TasksContext.Provider>
743+
</TasksDispatchContext>
744+
</TasksContext>
745745
);
746746
}
747747

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

928928
return (
929-
<TasksContext.Provider value={tasks}>
930-
<TasksDispatchContext.Provider value={dispatch}>
929+
<TasksContext value={tasks}>
930+
<TasksDispatchContext value={dispatch}>
931931
{children}
932-
</TasksDispatchContext.Provider>
933-
</TasksContext.Provider>
932+
</TasksDispatchContext>
933+
</TasksContext>
934934
);
935935
}
936936
```
@@ -968,11 +968,11 @@ export function TasksProvider({ children }) {
968968
);
969969

970970
return (
971-
<TasksContext.Provider value={tasks}>
972-
<TasksDispatchContext.Provider value={dispatch}>
971+
<TasksContext value={tasks}>
972+
<TasksDispatchContext value={dispatch}>
973973
{children}
974-
</TasksDispatchContext.Provider>
975-
</TasksContext.Provider>
974+
</TasksDispatchContext>
975+
</TasksContext>
976976
);
977977
}
978978

@@ -1179,11 +1179,11 @@ export function TasksProvider({ children }) {
11791179
);
11801180

11811181
return (
1182-
<TasksContext.Provider value={tasks}>
1183-
<TasksDispatchContext.Provider value={dispatch}>
1182+
<TasksContext value={tasks}>
1183+
<TasksDispatchContext value={dispatch}>
11841184
{children}
1185-
</TasksDispatchContext.Provider>
1186-
</TasksContext.Provider>
1185+
</TasksDispatchContext>
1186+
</TasksContext>
11871187
);
11881188
}
11891189

@@ -1368,4 +1368,3 @@ ul, li { margin: 0; padding: 0; }
13681368
- 你可以在你的应用程序中大量使用 context 和 reducer 的组合。
13691369
13701370
</Recap>
1371-

src/content/learn/typescript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ export default function MyApp() {
260260
const [theme, setTheme] = useState<Theme>('light');
261261

262262
return (
263-
<ThemeContext.Provider value={theme}>
263+
<ThemeContext value={theme}>
264264
<MyComponent />
265-
</ThemeContext.Provider>
265+
</ThemeContext>
266266
)
267267
}
268268

@@ -310,9 +310,9 @@ export default function MyApp() {
310310
const object = useMemo(() => ({ kind: "complex" }), []);
311311

312312
return (
313-
<Context.Provider value={object}>
313+
<Context value={object}>
314314
<MyComponent />
315-
</Context.Provider>
315+
</Context>
316316
)
317317
}
318318

0 commit comments

Comments
 (0)