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
Copy file name to clipboardExpand all lines: src/content/reference/react/StrictMode.md
+24-24
Original file line number
Diff line number
Diff line change
@@ -835,15 +835,15 @@ Strict Mode가 없으면 Effect를 클린업해야 한다는 사실을 놓치기
835
835
[Effect 클린업을 구현하는 방법에 대해 자세히 알아보세요.](/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development)
836
836
837
837
---
838
-
### Fixing bugs found by re-running ref callbacks in development {/*fixing-bugs-found-by-re-running-ref-callbacks-in-development*/}
838
+
### 개발 환경에서 ref 콜백을 다시 실행하여 발견된 버그 수정 {/*fixing-bugs-found-by-re-running-ref-callbacks-in-development*/}
839
839
840
-
Strict Mode can also help find bugs in [callbacks refs.](/learn/manipulating-the-dom-with-refs)
840
+
Strict Mode는 [callbacks refs](/learn/manipulating-the-dom-with-refs)의 버그를 찾는 데도 도움이 됩니다.
841
841
842
-
Every callback`ref` has some setup code and may have some cleanup code. Normally, React calls setup when the element is *created* (is added to the DOM) and calls cleanup when the element is *removed* (is removed from the DOM).
842
+
모든 콜백`ref`에는 몇 가지 셋업 코드가 있고 어쩌면 클린업 코드가 있을 수 있습니다. 일반적으로 React는 엘리먼트가 생성(DOM에 추가)될 때 셋업 코드를 실행하고, 엘리먼트가 제거(DOM에서 삭제)될 때 셋업 코드를 실행합니다.
843
843
844
-
When Strict Mode is on, React will also run **one extra setup+cleanup cycle in development for every callback `ref`.** This may feel surprising, but it helps reveal subtle bugs that are hard to catch manually.
844
+
Strict Mode가 켜져 있으면 React는 **모든 콜백 `ref`에 대해 개발 환경에서 한 번 더 셋업+클린업 사이클을 실행합니다.** 이외로 느껴질 수도 있지만, 수동으로 파악하기 어려운 미묘한 버그를 드러내는 데 도움이 됩니다.
845
845
846
-
Consider this example, which allows you to select an animal and then scroll to one of them. Notice when you switch from "Cats" to "Dogs", the console logs show that the number of animals in the list keeps growing, and the "Scroll to" buttons stop working:
846
+
다음 예시를 살펴봅시다. 이 예시는 동물을 선택한 후 목록 중 하나로 스크롤 할 수 있게 해줍니다. "cats"에서 "dogs"로 전환할 때 콘솔 로그를 보면 목록에 있는 동물의 수가 계속 증가하고, "Scroll to" 버튼이 동작하지 않게 되는 점을 확인할 수 있습니다.
847
847
848
848
<Sandpack>
849
849
@@ -901,9 +901,9 @@ export default function AnimalFriends() {
901
901
constlist=itemsRef.current;
902
902
constitem= {animal: animal, node};
903
903
list.push(item);
904
-
console.log(`✅ Adding animal to the map. Total animals: ${list.length}`);
904
+
console.log(`✅ 동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
905
905
if (list.length>10) {
906
-
console.log('❌ Too many animals in the list!');
906
+
console.log('❌ 목록에 동물이 너무 많습니다!');
907
907
}
908
908
return () => {
909
909
// 🚩 No cleanup, this is a bug!
@@ -963,9 +963,9 @@ li {
963
963
</Sandpack>
964
964
965
965
966
-
**This is a production bug!** Since the ref callback doesn't remove animals from the list in the cleanup, the list of animals keeps growing. This is a memory leak that can cause performance problems in a real app, and breaks the behavior of the app.
966
+
**이것은 프로덕션 버그입니다!** ref 콜백이 클린업 과정에서 동물 목록을 제거하지 않으므로 동물 목록이 계속 증가합니다. 이는 메모리 누수를 일으켜 실제 앱에서 성능 문제를 유발할 수 있으며, 앱의 동작을 망가뜨립니다.
967
967
968
-
The issue is the ref callback doesn't cleanup after itself:
968
+
문제는 ref 콜백이 스스로 클린업을 하지 않는 점입니다.
969
969
970
970
```js {6-8}
971
971
<li
@@ -980,7 +980,7 @@ The issue is the ref callback doesn't cleanup after itself:
980
980
</li>
981
981
```
982
982
983
-
Now let's wrap the original (buggy) code in `<StrictMode>`:
983
+
이제 원본 (버그가 있는) 코드를 `<StrictMode>`로 감싸봅시다.
984
984
985
985
<Sandpack>
986
986
@@ -1043,9 +1043,9 @@ export default function AnimalFriends() {
1043
1043
constlist=itemsRef.current;
1044
1044
constitem= {animal: animal, node}
1045
1045
list.push(item);
1046
-
console.log(`✅ Adding animal to the map. Total animals: ${list.length}`);
1046
+
console.log(`✅ 동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
1047
1047
if (list.length>10) {
1048
-
console.log('❌ Too many animals in the list!');
1048
+
console.log('❌ 목록에 동물이 너무 많습니다!');
1049
1049
}
1050
1050
return () => {
1051
1051
// 🚩 No cleanup, this is a bug!
@@ -1104,9 +1104,9 @@ li {
1104
1104
1105
1105
</Sandpack>
1106
1106
1107
-
**With Strict Mode, you immediately see that there is a problem**. Strict Mode runs an extra setup+cleanup cycle for every callback ref. This callback ref has no cleanup logic, so it adds refs but doesn't remove them. This is a hint that you're missing a cleanup function.
1107
+
**Strict Mode를 사용하면 문제를 즉시 찾을 수 있습니다.** Strict Mode는 모든 콜백 ref에 대해 추가적인 셋업+클린업 사이클을 실행 실행합니다. 이 콜백 ref에는 클린업 로직이 없기 때문에 ref를 추가만 하고 제거하지 않습니다. 이는 클린업 함수가 누락되었다는 힌트입니다.
1108
1108
1109
-
Strict Mode lets you eagerly find mistakes in callback refs. When you fix your callback by adding a cleanup function in Strict Mode, you *also* fix many possible future production bugs like the "Scroll to" bug from before:
1109
+
Strict Mode를 통해 콜백 ref에서 발생하는 실수를 조기에 발견할 수 있습니다. Strict Mode에서 클린업 함수를 추가해 콜백을 수정하면, 이전에 발생했던 "Scroll to" 버그와 같은 많은 잠재적인 프로덕션 버그도 함께 해결할 수 있습니다.
1110
1110
1111
1111
<Sandpack>
1112
1112
@@ -1169,13 +1169,13 @@ export default function AnimalFriends() {
1169
1169
constlist=itemsRef.current;
1170
1170
constitem= {animal, node};
1171
1171
list.push({animal: animal, node});
1172
-
console.log(`✅ Adding animal to the map. Total animals: ${list.length}`);
1172
+
console.log(`✅ 동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
1173
1173
if (list.length>10) {
1174
-
console.log('❌ Too many animals in the list!');
1174
+
console.log('❌ 목록에 동물이 너무 많습니다!');
1175
1175
}
1176
1176
return () => {
1177
1177
list.splice(list.indexOf(item));
1178
-
console.log(`❌ Removing animal from the map. Total animals: ${itemsRef.current.length}`);
1178
+
console.log(`❌ 목록에서 동물을 제거합니다. 전체 동물 수: ${itemsRef.current.length}`);
1179
1179
}
1180
1180
}}
1181
1181
>
@@ -1231,23 +1231,23 @@ li {
1231
1231
1232
1232
</Sandpack>
1233
1233
1234
-
Now on inital mount in StrictMode, the ref callbacks are all setup, cleaned up, and setup again:
1234
+
이제 StrictMode에서 초기 마운트 시, ref 콜백이 모두 셋업되고, 클린업 후, 다시 셋업 됩니다.
1235
1235
1236
1236
```
1237
1237
...
1238
-
✅ Adding animal to the map. Total animals:10
1238
+
✅ 동물을 목록에 추가하는 중. 총 동물 수:10
1239
1239
...
1240
-
❌ Removing animal from the map. Total animals:0
1240
+
❌ 목록에서 동물을 제거합니다. 총 동물 수:0
1241
1241
...
1242
-
✅ Adding animal to the map. Total animals:10
1242
+
✅ 동물을 목록에 추가하는 중. 총 동물 수:10
1243
1243
```
1244
1244
1245
-
**This is expected.** Strict Mode confirms that the ref callbacks are cleaned up correctly, so the size never grows above the expected amount. After the fix, there are no memory leaks, and all the features work as expected.
1245
+
**이것이 예상된 결과입니다.** Strict Mode는 ref 콜백이 올바르게 클린업 되었는지 확인해 주기 때문에 크기가 예상된 양을 초과하지 않습니다. 수정 후에는 메모리 누수가 발생하지 않으며, 모든 기능이 예상대로 작동합니다.
1246
1246
1247
-
Without Strict Mode, it was easy to miss the bug until you clicked around to app to notice broken features. Strict Mode made the bugs appear right away, before you push them to production.
1247
+
Strict Mode 없이는 고장 난 기능을 알아차릴 때까지 여기저기 클릭해야 하므로 버그를 놓치기 쉽습니다. Strict Mode는 버그를 즉시 드러나도록 하여 프로덕션에 배포하기 전에 문제를 발견할 수 있습니다.
1248
1248
1249
1249
---
1250
-
### Fixing deprecation warnings enabled by Strict Mode {/*fixing-deprecation-warnings-enabled-by-strict-mode*/}
1250
+
### Strict Mode에서 활성화된 더 이상 사용되지 않는 경고 수정하기 {/*fixing-deprecation-warnings-enabled-by-strict-mode*/}
1251
1251
1252
1252
React는 `<StrictMode>` 트리 내부의 컴포넌트가 더 이상 사용되지 않는 다음 API 중 하나를 사용하는 경우 경고를 표시합니다.
0 commit comments