You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: src/content/learn/preserving-and-resetting-state.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -671,13 +671,13 @@ label {
671
671
672
672
</Sandpack>
673
673
674
-
체크 박스를 선택할 때 카운터 state가 초기화됩니다. `div`의 첫 번째 자식으로 `Counter`를 렌더링하는 것에서 `section`의 첫 번째 자식으로 바꾸지만요. 자식 `div`가 DOM에서 제거될 때 그것의 전체 하위 트리(`Counter`와 그 state를 포함해서)는 제거됩니다.
674
+
`Counter`의 State는 체크 박스를 선택할 때 초기화됩니다. 비록 `Counter`를 렌더링하지만, `div`의 첫 번째 자식이 `section`에서 `div`로 바뀝니다. 자식 `section`이 DOM에서 제거되었을 때, 그 아래 전체 트리(`Counter`와 그 State를 포함하여)도 함께 제거됩니다.
675
675
676
676
<DiagramGroup>
677
677
678
678
<Diagramname="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.">
679
679
680
-
`section`이 `div`로 바뀌면, `section`은 삭제되고 새로운 `div`가 추가됩니다
680
+
`section`이 `div`로 바뀌면, `section`은 삭제되고 새로운 `div`가 추가됩니다.
681
681
682
682
</Diagram>
683
683
@@ -687,17 +687,17 @@ label {
687
687
688
688
<Diagramname="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.">
689
689
690
-
다시 되돌리면, `div`는 삭제되고 새로운 `section`이 추가됩니다.
690
+
다시 되돌리면, `div`는 삭제되고 새로운 `section`이 추가됩니다.
691
691
692
692
</Diagram>
693
693
694
694
</DiagramGroup>
695
695
696
-
경험상(rule of thumb)**리렌더링할 때 state를 유지하고 싶다면, 트리 구조가 "같아야" 합니다.** 만약 구조가 다르다면 React가 트리에서 컴포넌트를 지울 때 state로 지우기 때문에 state가 유지되지 않습니다.
696
+
경험상<sup>Rule of Thumb</sup>**리렌더링할 때 State를 유지하고 싶다면, 트리 구조가 "같아야" 합니다.** 만약 구조가 다르다면 React가 트리에서 컴포넌트를 지울 때 State로 지우기 때문에 State가 유지되지 않습니다.
697
697
698
698
<Pitfall>
699
699
700
-
이것이 컴포넌트 함수를 중첩해서 정의하면 안 되는 이유입니다.
700
+
이것이 컴포넌트 함수를 중첩해서 정의하면 안되는 이유입니다.
701
701
702
702
여기, `MyComponent` 안에서 `MyTextField` 컴포넌트 함수를 정의하고 있습니다.
703
703
@@ -734,13 +734,13 @@ export default function MyComponent() {
734
734
</Sandpack>
735
735
736
736
737
-
버튼을 누를 때마다 입력 state가 사라집니다! 이것은 `MyComponent`를 렌더링할 때마다 *다른*`MyTextField` 함수가 만들어지기 때문입니다. 따라서 같은 함수에서 *다른* 컴포넌트를 렌더링할 때마다 React는 그 아래의 모든 state를 초기화합니다. 이런 문제를 피하려면 **항상 컴포넌트를 중첩해서 정의하지 않고 최상위 범위에서 정의해야 합니다.**
737
+
버튼을 누를 때마다 입력 State가 사라집니다! 이것은 `MyComponent`를 렌더링할 때마다 *다른*`MyTextField` 함수가 만들어지기 때문입니다. 따라서 같은 함수에서 *다른* 컴포넌트를 렌더링할 때마다 React는 그 아래의 모든 state를 초기화합니다. 이런 문제를 피하려면 **항상 컴포넌트를 중첩해서 정의하지 않고 최상위 범위에서 정의해야 합니다.**
738
738
739
739
</Pitfall>
740
740
741
741
## 같은 위치에서 state를 초기화하기 {/*resetting-state-at-the-same-position*/}
742
742
743
-
기본적으로 React는 컴포넌트가 같은 위치를 유지하면 state를 유지합니다. 보통 이것이 당신이 원하는 행동이기 때문에 기본 동작으로서 타당합니다. 그러나 가끔 컴포넌트 state를 초기화하고 싶을 때가 있습니다. 두 선수가 턴마다 자신의 점수를 추적하는 앱을 한번 봅시다.
743
+
기본적으로 React는 컴포넌트가 같은 위치를 유지하면 state를 유지합니다. 보통 이것이 당신이 원하는 행동이기 때문에 기본 동작으로서 타당합니다. 그러나 가끔 컴포넌트 State를 초기화하고 싶을 때가 있습니다. 두 선수가 턴마다 자신의 점수를 추적하는 앱을 한번 봅시다.
0 commit comments