Skip to content

Sync with react.dev @ 50d6991c #1210

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

Merged
merged 18 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
7 changes: 5 additions & 2 deletions .github/workflows/analyze_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
types:
- completed

permissions: {}

permissions:
contents: read
issues: write
pull-requests: write

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 @@ -1199,7 +1199,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 @@ -1219,7 +1219,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 @@ -282,7 +282,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
5 changes: 5 additions & 0 deletions src/content/community/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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
26 changes: 13 additions & 13 deletions src/content/learn/keeping-components-pure.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,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 @@ -243,7 +243,7 @@ React에서, **사이드 이펙트는 보통 [이벤트 핸들러](/learn/respon

```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 @@ -305,7 +305,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 @@ -604,14 +604,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();

// HACK: Prevent the memory from growing forever while you read docs.
// We're breaking our own rules here.
Expand Down Expand Up @@ -700,14 +700,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();

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

// Does not affect the original array:
storiesToDisplay.push({
Expand All @@ -792,14 +792,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();

// HACK: Prevent the memory from growing forever while you read docs.
// We're breaking our own rules here.
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 @@ -741,9 +741,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 @@ -836,13 +836,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
14 changes: 7 additions & 7 deletions src/content/learn/preserving-and-resetting-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,13 @@ label {

</Sandpack>

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

<DiagramGroup>

<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.">

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

</Diagram>

Expand All @@ -687,17 +687,17 @@ label {

<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.">

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

</Diagram>

</DiagramGroup>

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

<Pitfall>

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

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

Expand Down Expand Up @@ -734,13 +734,13 @@ export default function MyComponent() {
</Sandpack>


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

</Pitfall>

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

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

<Sandpack>

Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/referencing-values-with-refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export default function Toggle() {

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

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

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

Expand Down
56 changes: 28 additions & 28 deletions src/content/learn/scaling-up-with-reducer-and-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,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 @@ -509,8 +509,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 @@ -520,8 +520,8 @@ export default function TaskApp() {
onChangeTask={handleChangeTask}
onDeleteTask={handleDeleteTask}
/>
</TasksDispatchContext.Provider>
</TasksContext.Provider>
</TasksDispatchContext>
</TasksContext>
);
}

Expand Down Expand Up @@ -676,13 +676,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>
```

대신 필요한 컴포넌트에서는 `TaskContext`에서 `tasks` 리스트를 읽을 수 있습니다.
Expand Down Expand Up @@ -730,13 +730,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 @@ -921,11 +921,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 @@ -963,11 +963,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 @@ -1174,11 +1174,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
Loading