Skip to content

Commit cf47248

Browse files
authored
Sync with react.dev @ 50d6991 (#1210)
This PR was automatically generated. Merge changes from [react.dev](https://github.com/reactjs/react.dev/commits/main) at 50d6991 The following files have conflicts and may need new translations: * [ ] [src/content/blog/2024/12/05/react-19.md](/reactjs/react.dev/commits/main/src/content/blog/2024/12/05/react-19.md) * [ ] [src/content/learn/preserving-and-resetting-state.md](/reactjs/react.dev/commits/main/src/content/learn/preserving-and-resetting-state.md) * [ ] [src/content/learn/referencing-values-with-refs.md](/reactjs/react.dev/commits/main/src/content/learn/referencing-values-with-refs.md) * [ ] [src/content/reference/react-dom/createPortal.md](/reactjs/react.dev/commits/main/src/content/reference/react-dom/createPortal.md) * [ ] [src/content/reference/react-dom/static/prerender.md](/reactjs/react.dev/commits/main/src/content/reference/react-dom/static/prerender.md) * [ ] [src/content/reference/react-dom/static/prerenderToNodeStream.md](/reactjs/react.dev/commits/main/src/content/reference/react-dom/static/prerenderToNodeStream.md) * [ ] [src/content/reference/react/createContext.md](/reactjs/react.dev/commits/main/src/content/reference/react/createContext.md) * [ ] [src/content/reference/react/legacy.md](/reactjs/react.dev/commits/main/src/content/reference/react/legacy.md) * [ ] [src/content/reference/react/useContext.md](/reactjs/react.dev/commits/main/src/content/reference/react/useContext.md) * [ ] [src/content/reference/rsc/server-functions.md](/reactjs/react.dev/commits/main/src/content/reference/rsc/server-functions.md) * [ ] [src/content/reference/rules/components-and-hooks-must-be-pure.md](/reactjs/react.dev/commits/main/src/content/reference/rules/components-and-hooks-must-be-pure.md) Please fix the conflicts by pushing new commits to this pull request, either by editing the files directly on GitHub or by checking out this branch. ## DO NOT SQUASH MERGE THIS PULL REQUEST! Doing so will "erase" the commits from main and cause them to show up as conflicts the next time we merge.
2 parents 9296f70 + 7813145 commit cf47248

24 files changed

+171
-157
lines changed

.github/workflows/analyze_comment.yml

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

9-
permissions: {}
10-
9+
permissions:
10+
contents: read
11+
issues: write
12+
pull-requests: write
13+
1114
jobs:
1215
comment:
1316
runs-on: ubuntu-latest

src/components/Layout/HomeContent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ async function Talks({ confId }) {
11991199
</CodeBlock>
12001200
}
12011201
right={
1202-
<NavContext.Provider value={{slug, navigate}}>
1202+
<NavContext value={{slug, navigate}}>
12031203
<BrowserChrome
12041204
domain="example.com"
12051205
path={'confs/' + slug}
@@ -1219,7 +1219,7 @@ async function Talks({ confId }) {
12191219
</Suspense>
12201220
</ExamplePanel>
12211221
</BrowserChrome>
1222-
</NavContext.Provider>
1222+
</NavContext>
12231223
}
12241224
/>
12251225
);

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
@@ -282,7 +282,9 @@ export default function TopNav({
282282
<BrandMenu>
283283
<div className="flex items-center">
284284
<div className="uwu-visible flex items-center justify-center h-full">
285-
<NextLink href="/">
285+
<NextLink
286+
href="/"
287+
className="active:scale-95 transition-transform">
286288
<Image
287289
alt="logo by @sawaratsuki1004"
288290
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/community/conferences.md

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

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

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

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: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function Cup({ guest }) {
175175
}
176176

177177
export default function TeaGathering() {
178-
let cups = [];
178+
const cups = [];
179179
for (let i = 1; i <= 12; i++) {
180180
cups.push(<Cup key={i} guest={i} />);
181181
}
@@ -243,7 +243,7 @@ React에서, **사이드 이펙트는 보통 [이벤트 핸들러](/learn/respon
243243

244244
```js src/Clock.js active
245245
export default function Clock({ time }) {
246-
let hours = time.getHours();
246+
const hours = time.getHours();
247247
if (hours >= 0 && hours <= 6) {
248248
document.getElementById('time').className = 'night';
249249
} else {
@@ -305,7 +305,7 @@ body > * {
305305

306306
```js src/Clock.js active
307307
export default function Clock({ time }) {
308-
let hours = time.getHours();
308+
const hours = time.getHours();
309309
let className;
310310
if (hours >= 0 && hours <= 6) {
311311
className = 'night';
@@ -604,14 +604,14 @@ export default function StoryTray({ stories }) {
604604
import { useState, useEffect } from 'react';
605605
import StoryTray from './StoryTray.js';
606606

607-
let initialStories = [
607+
const initialStories = [
608608
{id: 0, label: "Ankit's Story" },
609609
{id: 1, label: "Taylor's Story" },
610610
];
611611

612612
export default function App() {
613-
let [stories, setStories] = useState([...initialStories])
614-
let time = useTime();
613+
const [stories, setStories] = useState([...initialStories])
614+
const time = useTime();
615615

616616
// HACK: Prevent the memory from growing forever while you read docs.
617617
// We're breaking our own rules here.
@@ -700,14 +700,14 @@ export default function StoryTray({ stories }) {
700700
import { useState, useEffect } from 'react';
701701
import StoryTray from './StoryTray.js';
702702

703-
let initialStories = [
703+
const initialStories = [
704704
{id: 0, label: "Ankit's Story" },
705705
{id: 1, label: "Taylor's Story" },
706706
];
707707

708708
export default function App() {
709-
let [stories, setStories] = useState([...initialStories])
710-
let time = useTime();
709+
const [stories, setStories] = useState([...initialStories])
710+
const time = useTime();
711711

712712
// HACK: Prevent the memory from growing forever while you read docs.
713713
// We're breaking our own rules here.
@@ -768,7 +768,7 @@ li {
768768
```js src/StoryTray.js active
769769
export default function StoryTray({ stories }) {
770770
// Copy the array!
771-
let storiesToDisplay = stories.slice();
771+
const storiesToDisplay = stories.slice();
772772

773773
// Does not affect the original array:
774774
storiesToDisplay.push({
@@ -792,14 +792,14 @@ export default function StoryTray({ stories }) {
792792
import { useState, useEffect } from 'react';
793793
import StoryTray from './StoryTray.js';
794794

795-
let initialStories = [
795+
const initialStories = [
796796
{id: 0, label: "Ankit's Story" },
797797
{id: 1, label: "Taylor's Story" },
798798
];
799799

800800
export default function App() {
801-
let [stories, setStories] = useState([...initialStories])
802-
let time = useTime();
801+
const [stories, setStories] = useState([...initialStories])
802+
const time = useTime();
803803

804804
// HACK: Prevent the memory from growing forever while you read docs.
805805
// We're breaking our own rules here.

src/content/learn/managing-state.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ export default function Section({ children }) {
741741
const level = useContext(LevelContext);
742742
return (
743743
<section className="section">
744-
<LevelContext.Provider value={level + 1}>
744+
<LevelContext value={level + 1}>
745745
{children}
746-
</LevelContext.Provider>
746+
</LevelContext>
747747
</section>
748748
);
749749
}
@@ -836,13 +836,11 @@ export function TasksProvider({ children }) {
836836
);
837837
838838
return (
839-
<TasksContext.Provider value={tasks}>
840-
<TasksDispatchContext.Provider
841-
value={dispatch}
842-
>
839+
<TasksContext value={tasks}>
840+
<TasksDispatchContext value={dispatch}>
843841
{children}
844-
</TasksDispatchContext.Provider>
845-
</TasksContext.Provider>
842+
</TasksDispatchContext>
843+
</TasksContext>
846844
);
847845
}
848846

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -671,13 +671,13 @@ label {
671671

672672
</Sandpack>
673673

674-
체크 박스를 선택할 때 카운터 state가 초기화됩니다. `div`의 첫 번째 자식으로 `Counter`렌더링하는 것에서 `section`의 첫 번째 자식으로 바꾸지만요. 자식 `div` DOM에서 제거될 때 그것의 전체 하위 트리(`Counter`와 그 state를 포함해서)는 제거됩니다.
674+
`Counter`의 State는 체크 박스를 선택할 때 초기화됩니다. 비록 `Counter`렌더링하지만, `div`의 첫 번째 자식이 `section`에서 `div`로 바뀝니다. 자식 `section` DOM에서 제거되었을 때, 그 아래 전체 트리(`Counter`와 그 State를 포함하여)도 함께 제거됩니다.
675675

676676
<DiagramGroup>
677677

678678
<Diagram name="preserving_state_diff_same_pt1" height={350} width={794} alt="Diagram with three sections, with an arrow transitioning each section in between. The first section contains a React component labeled 'div' with a single child labeled 'section', which has a single child labeled 'Counter' containing a state bubble labeled 'count' with value 3. The middle section has the same 'div' parent, but the child components have now been deleted, indicated by a yellow 'proof' image. The third section has the same 'div' parent again, now with a new child labeled 'div', highlighted in yellow, also with a new child labeled 'Counter' containing a state bubble labeled 'count' with value 0, all highlighted in yellow.">
679679

680-
`section` `div` 로 바뀌면, `section` 은 삭제되고 새로운 `div` 가 추가됩니다
680+
`section``div`로 바뀌면, `section`은 삭제되고 새로운 `div`가 추가됩니다.
681681

682682
</Diagram>
683683

@@ -687,17 +687,17 @@ label {
687687

688688
<Diagram name="preserving_state_diff_same_pt2" height={350} width={794} alt="Diagram with three sections, with an arrow transitioning each section in between. The first section contains a React component labeled 'div' with a single child labeled 'div', which has a single child labeled 'Counter' containing a state bubble labeled 'count' with value 0. The middle section has the same 'div' parent, but the child components have now been deleted, indicated by a yellow 'proof' image. The third section has the same 'div' parent again, now with a new child labeled 'section', highlighted in yellow, also with a new child labeled 'Counter' containing a state bubble labeled 'count' with value 0, all highlighted in yellow.">
689689

690-
다시 되돌리면, `div` 는 삭제되고 새로운 `section` 이 추가됩니다.
690+
다시 되돌리면, `div`는 삭제되고 새로운 `section`이 추가됩니다.
691691

692692
</Diagram>
693693

694694
</DiagramGroup>
695695

696-
경험상(rule of thumb) **리렌더링할 때 state를 유지하고 싶다면, 트리 구조가 "같아야" 합니다.** 만약 구조가 다르다면 React가 트리에서 컴포넌트를 지울 때 state로 지우기 때문에 state가 유지되지 않습니다.
696+
경험상<sup>Rule of Thumb</sup> **리렌더링할 때 State를 유지하고 싶다면, 트리 구조가 "같아야" 합니다.** 만약 구조가 다르다면 React가 트리에서 컴포넌트를 지울 때 State로 지우기 때문에 State가 유지되지 않습니다.
697697

698698
<Pitfall>
699699

700-
이것이 컴포넌트 함수를 중첩해서 정의하면 안 되는 이유입니다.
700+
이것이 컴포넌트 함수를 중첩해서 정의하면 안되는 이유입니다.
701701

702702
여기, `MyComponent` 안에서 `MyTextField` 컴포넌트 함수를 정의하고 있습니다.
703703

@@ -734,13 +734,13 @@ export default function MyComponent() {
734734
</Sandpack>
735735

736736

737-
버튼을 누를 때마다 입력 state가 사라집니다! 이것은 `MyComponent`를 렌더링할 때마다 *다른* `MyTextField` 함수가 만들어지기 때문입니다. 따라서 같은 함수에서 *다른* 컴포넌트를 렌더링할 때마다 React는 그 아래의 모든 state를 초기화합니다. 이런 문제를 피하려면 **항상 컴포넌트를 중첩해서 정의하지 않고 최상위 범위에서 정의해야 합니다.**
737+
버튼을 누를 때마다 입력 State가 사라집니다! 이것은 `MyComponent`를 렌더링할 때마다 *다른* `MyTextField` 함수가 만들어지기 때문입니다. 따라서 같은 함수에서 *다른* 컴포넌트를 렌더링할 때마다 React는 그 아래의 모든 state를 초기화합니다. 이런 문제를 피하려면 **항상 컴포넌트를 중첩해서 정의하지 않고 최상위 범위에서 정의해야 합니다.**
738738

739739
</Pitfall>
740740

741741
## 같은 위치에서 state를 초기화하기 {/*resetting-state-at-the-same-position*/}
742742

743-
기본적으로 React는 컴포넌트가 같은 위치를 유지하면 state를 유지합니다. 보통 이것이 당신이 원하는 행동이기 때문에 기본 동작으로서 타당합니다. 그러나 가끔 컴포넌트 state를 초기화하고 싶을 때가 있습니다. 두 선수가 턴마다 자신의 점수를 추적하는 앱을 한번 봅시다.
743+
기본적으로 React는 컴포넌트가 같은 위치를 유지하면 state를 유지합니다. 보통 이것이 당신이 원하는 행동이기 때문에 기본 동작으로서 타당합니다. 그러나 가끔 컴포넌트 State를 초기화하고 싶을 때가 있습니다. 두 선수가 턴마다 자신의 점수를 추적하는 앱을 한번 봅시다.
744744

745745
<Sandpack>
746746

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

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

463463
#### debouncing 수정 {/*fix-debouncing*/}
464464

465-
예시에서 모든 버튼 클릭 핸들러는 ["debounced"](https://redd.one/blog/debounce-vs-throttle)입니다. 어떤 의미인지 보려면 버튼 중 하나를 누르세요. 1초 후에 메시지가 어떻게 표시되는지 확인해볼게요. 메시지 대기 중에 버튼을 누르면 타이머가 리셋됩니다. 따라서 같은 버튼을 여러 번 빠르게 클릭하면 *다음* 클릭이 멈출 때까지 메시지가 나타나지 않습니다. debouncing을 사용하면 사용자가 "작업이 중지될" 때까지 일부 작업을 지연시킬 수 있습니다.
465+
예시에서 모든 버튼 클릭 핸들러는 ["debounced"](https://redd.one/blog/debounce-vs-throttle)됩니다. 어떤 의미인지 보려면 버튼 중 하나를 누르세요. 1초 후에 메시지가 어떻게 표시되는지 확인해볼게요. 메시지 대기 중에 버튼을 누르면 타이머가 리셋됩니다. 따라서 같은 버튼을 여러 번 빠르게 클릭하면 *다음* 클릭이 멈출 때까지 메시지가 나타나지 않습니다. Debouncing을 사용하면 사용자가 "작업이 중지될" 때까지 일부 작업을 지연시킬 수 있습니다.
466466

467467
예시는 작동하지만, 의도한 대로 작동하지 않습니다. 버튼은 독립적이지 않습니다. 문제를 보려면 버튼 중 하나를 클릭한 다음 즉시 다른 버튼을 클릭합니다. 지연된 후에 양쪽 버튼의 메시지를 볼 수 있을 것이라고 예상할 것입니다. 그러나 마지막 버튼의 메시지만 표시됩니다. 첫 번째 버튼의 메시지가 사라집니다.
468468

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,11 @@ export default function TaskApp() {
461461
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks);
462462
// ...
463463
return (
464-
<TasksContext.Provider value={tasks}>
465-
<TasksDispatchContext.Provider value={dispatch}>
464+
<TasksContext value={tasks}>
465+
<TasksDispatchContext value={dispatch}>
466466
...
467-
</TasksDispatchContext.Provider>
468-
</TasksContext.Provider>
467+
</TasksDispatchContext>
468+
</TasksContext>
469469
);
470470
}
471471
```
@@ -509,8 +509,8 @@ export default function TaskApp() {
509509
}
510510

511511
return (
512-
<TasksContext.Provider value={tasks}>
513-
<TasksDispatchContext.Provider value={dispatch}>
512+
<TasksContext value={tasks}>
513+
<TasksDispatchContext value={dispatch}>
514514
<h1>Day off in Kyoto</h1>
515515
<AddTask
516516
onAddTask={handleAddTask}
@@ -520,8 +520,8 @@ export default function TaskApp() {
520520
onChangeTask={handleChangeTask}
521521
onDeleteTask={handleDeleteTask}
522522
/>
523-
</TasksDispatchContext.Provider>
524-
</TasksContext.Provider>
523+
</TasksDispatchContext>
524+
</TasksContext>
525525
);
526526
}
527527

@@ -676,13 +676,13 @@ ul, li { margin: 0; padding: 0; }
676676
이제 `tasks` 리스트나 이벤트 핸들러를 트리 아래로 전달할 필요가 없습니다.
677677

678678
```js {4-5}
679-
<TasksContext.Provider value={tasks}>
680-
<TasksDispatchContext.Provider value={dispatch}>
679+
<TasksContext value={tasks}>
680+
<TasksDispatchContext value={dispatch}>
681681
<h1>Day off in Kyoto</h1>
682682
<AddTask />
683683
<TaskList />
684-
</TasksDispatchContext.Provider>
685-
</TasksContext.Provider>
684+
</TasksDispatchContext>
685+
</TasksContext>
686686
```
687687

688688
대신 필요한 컴포넌트에서는 `TaskContext`에서 `tasks` 리스트를 읽을 수 있습니다.
@@ -730,13 +730,13 @@ export default function TaskApp() {
730730
);
731731

732732
return (
733-
<TasksContext.Provider value={tasks}>
734-
<TasksDispatchContext.Provider value={dispatch}>
733+
<TasksContext value={tasks}>
734+
<TasksDispatchContext value={dispatch}>
735735
<h1>Day off in Kyoto</h1>
736736
<AddTask />
737737
<TaskList />
738-
</TasksDispatchContext.Provider>
739-
</TasksContext.Provider>
738+
</TasksDispatchContext>
739+
</TasksContext>
740740
);
741741
}
742742

@@ -921,11 +921,11 @@ export function TasksProvider({ children }) {
921921
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks);
922922

923923
return (
924-
<TasksContext.Provider value={tasks}>
925-
<TasksDispatchContext.Provider value={dispatch}>
924+
<TasksContext value={tasks}>
925+
<TasksDispatchContext value={dispatch}>
926926
{children}
927-
</TasksDispatchContext.Provider>
928-
</TasksContext.Provider>
927+
</TasksDispatchContext>
928+
</TasksContext>
929929
);
930930
}
931931
```
@@ -963,11 +963,11 @@ export function TasksProvider({ children }) {
963963
);
964964

965965
return (
966-
<TasksContext.Provider value={tasks}>
967-
<TasksDispatchContext.Provider value={dispatch}>
966+
<TasksContext value={tasks}>
967+
<TasksDispatchContext value={dispatch}>
968968
{children}
969-
</TasksDispatchContext.Provider>
970-
</TasksContext.Provider>
969+
</TasksDispatchContext>
970+
</TasksContext>
971971
);
972972
}
973973

@@ -1174,11 +1174,11 @@ export function TasksProvider({ children }) {
11741174
);
11751175

11761176
return (
1177-
<TasksContext.Provider value={tasks}>
1178-
<TasksDispatchContext.Provider value={dispatch}>
1177+
<TasksContext value={tasks}>
1178+
<TasksDispatchContext value={dispatch}>
11791179
{children}
1180-
</TasksDispatchContext.Provider>
1181-
</TasksContext.Provider>
1180+
</TasksDispatchContext>
1181+
</TasksContext>
11821182
);
11831183
}
11841184

0 commit comments

Comments
 (0)