Skip to content

Commit c217cfb

Browse files
docs: translate Ref in StrictMode section (#1162)
# StrictMode에서 ref callbacks 번역작업 https://ko.react.dev/reference/react/StrictMode 위 링크에 해당하는 페이지에서 `Fixing bugs found by re-running ref callbacks in development` 주제에 대해 번역 하였습니다. ## 필수 확인 사항 - [x] [기여자 행동 강령 규약<sup>Code of Conduct</sup>](https://github.com/reactjs/ko.react.dev/blob/main/CODE_OF_CONDUCT.md) - [x] [기여 가이드라인<sup>Contributing</sup>](https://github.com/reactjs/ko.react.dev/blob/main/CONTRIBUTING.md) - [x] [공통 스타일 가이드<sup>Universal Style Guide</sup>](https://github.com/reactjs/ko.react.dev/blob/main/wiki/universal-style-guide.md) - [x] [번역을 위한 모범 사례<sup>Best Practices for Translation</sup>](https://github.com/reactjs/ko.react.dev/blob/main/wiki/best-practices-for-translation.md) - [x] [번역 용어 정리<sup>Translate Glossary</sup>](https://github.com/reactjs/ko.react.dev/blob/main/wiki/translate-glossary.md) - [x] [`textlint` 가이드<sup>Textlint Guide</sup>](https://github.com/reactjs/ko.react.dev/blob/main/wiki/textlint-guide.md) - [x] [맞춤법 검사<sup>Spelling Check</sup>](https://nara-speller.co.kr/speller/) ## 선택 확인 사항 - [ ] 번역 초안 작성<sup>Draft Translation</sup> - [ ] 리뷰 반영<sup>Resolve Reviews</sup> --------- Co-authored-by: 루밀LuMir <[email protected]>
1 parent 731c6ac commit c217cfb

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

Diff for: src/content/reference/react/StrictMode.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -835,15 +835,15 @@ Strict Mode가 없으면 Effect를 클린업해야 한다는 사실을 놓치기
835835
[Effect 클린업을 구현하는 방법에 대해 자세히 알아보세요.](/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development)
836836
837837
---
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*/}
839839
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)의 버그를 찾는 데도 도움이 됩니다.
841841
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에서 삭제)될 때 셋업 코드를 실행합니다.
843843
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`에 대해 개발 환경에서 한 번 더 셋업+클린업 사이클을 실행합니다.** 이외로 느껴질 수도 있지만, 수동으로 파악하기 어려운 미묘한 버그를 드러내는 데 도움이 됩니다.
845845
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" 버튼이 동작하지 않게 되는 점을 확인할 수 있습니다.
847847
848848
<Sandpack>
849849
@@ -901,9 +901,9 @@ export default function AnimalFriends() {
901901
const list = itemsRef.current;
902902
const item = {animal: animal, node};
903903
list.push(item);
904-
console.log(`Adding animal to the map. Total animals: ${list.length}`);
904+
console.log(`동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
905905
if (list.length > 10) {
906-
console.log('Too many animals in the list!');
906+
console.log('목록에 동물이 너무 많습니다!');
907907
}
908908
return () => {
909909
// 🚩 No cleanup, this is a bug!
@@ -963,9 +963,9 @@ li {
963963
</Sandpack>
964964
965965
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 콜백이 클린업 과정에서 동물 목록을 제거하지 않으므로 동물 목록이 계속 증가합니다. 이는 메모리 누수를 일으켜 실제 앱에서 성능 문제를 유발할 수 있으며, 앱의 동작을 망가뜨립니다.
967967
968-
The issue is the ref callback doesn't cleanup after itself:
968+
문제는 ref 콜백이 스스로 클린업을 하지 않는 점입니다.
969969
970970
```js {6-8}
971971
<li
@@ -980,7 +980,7 @@ The issue is the ref callback doesn't cleanup after itself:
980980
</li>
981981
```
982982
983-
Now let's wrap the original (buggy) code in `<StrictMode>`:
983+
이제 원본 (버그가 있는) 코드를 `<StrictMode>`로 감싸봅시다.
984984
985985
<Sandpack>
986986
@@ -1043,9 +1043,9 @@ export default function AnimalFriends() {
10431043
const list = itemsRef.current;
10441044
const item = {animal: animal, node}
10451045
list.push(item);
1046-
console.log(`Adding animal to the map. Total animals: ${list.length}`);
1046+
console.log(`동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
10471047
if (list.length > 10) {
1048-
console.log('Too many animals in the list!');
1048+
console.log('목록에 동물이 너무 많습니다!');
10491049
}
10501050
return () => {
10511051
// 🚩 No cleanup, this is a bug!
@@ -1104,9 +1104,9 @@ li {
11041104
11051105
</Sandpack>
11061106
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를 추가만 하고 제거하지 않습니다. 이는 클린업 함수가 누락되었다는 힌트입니다.
11081108
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" 버그와 같은 많은 잠재적인 프로덕션 버그도 함께 해결할 수 있습니다.
11101110
11111111
<Sandpack>
11121112
@@ -1169,13 +1169,13 @@ export default function AnimalFriends() {
11691169
const list = itemsRef.current;
11701170
const item = {animal, node};
11711171
list.push({animal: animal, node});
1172-
console.log(`Adding animal to the map. Total animals: ${list.length}`);
1172+
console.log(`동물을 목록에 추가하는 중. 총 동물 수: ${list.length}`);
11731173
if (list.length > 10) {
1174-
console.log('Too many animals in the list!');
1174+
console.log('목록에 동물이 너무 많습니다!');
11751175
}
11761176
return () => {
11771177
list.splice(list.indexOf(item));
1178-
console.log(`Removing animal from the map. Total animals: ${itemsRef.current.length}`);
1178+
console.log(`목록에서 동물을 제거합니다. 전체 동물 수: ${itemsRef.current.length}`);
11791179
}
11801180
}}
11811181
>
@@ -1231,23 +1231,23 @@ li {
12311231
12321232
</Sandpack>
12331233
1234-
Now on inital mount in StrictMode, the ref callbacks are all setup, cleaned up, and setup again:
1234+
이제 StrictMode에서 초기 마운트 시, ref 콜백이 모두 셋업되고, 클린업 후, 다시 셋업 됩니다.
12351235
12361236
```
12371237
...
1238-
Adding animal to the map. Total animals: 10
1238+
동물을 목록에 추가하는 중. 총 동물 수: 10
12391239
...
1240-
Removing animal from the map. Total animals: 0
1240+
목록에서 동물을 제거합니다. 총 동물 수: 0
12411241
...
1242-
Adding animal to the map. Total animals: 10
1242+
동물을 목록에 추가하는 중. 총 동물 수: 10
12431243
```
12441244
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 콜백이 올바르게 클린업 되었는지 확인해 주기 때문에 크기가 예상된 양을 초과하지 않습니다. 수정 후에는 메모리 누수가 발생하지 않으며, 모든 기능이 예상대로 작동합니다.
12461246
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는 버그를 즉시 드러나도록 하여 프로덕션에 배포하기 전에 문제를 발견할 수 있습니다.
12481248
12491249
---
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*/}
12511251
12521252
React는 `<StrictMode>` 트리 내부의 컴포넌트가 더 이상 사용되지 않는 다음 API 중 하나를 사용하는 경우 경고를 표시합니다.
12531253

0 commit comments

Comments
 (0)