Skip to content

Commit d50a0d3

Browse files
committed
wip
1 parent 3c05883 commit d50a0d3

File tree

1 file changed

+19
-19
lines changed
  • src/content/reference/eslint-plugin-react-hooks/lints

1 file changed

+19
-19
lines changed

src/content/reference/eslint-plugin-react-hooks/lints/globals.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@ title: globals
44

55
<Intro>
66

7-
Validates against assignment/mutation of globals during render, part of ensuring that [side effects must run outside of render](/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render).
7+
렌더링 중 전역 변수의 할당/변이를 검증합니다. 이는 [사이드 이펙트는 렌더링 외부에서 실행되어야 합니다](/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) 규칙을 보장하는 일부입니다.
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## 규칙 세부 사항 {/*rule-details*/}
1212

13-
Global variables exist outside React's control. When you modify them during render, you break React's assumption that rendering is pure. This can cause components to behave differently in development vs production, break Fast Refresh, and make your app impossible to optimize with features like React Compiler.
13+
전역 변수는 React의 제어 범위 밖에 존재합니다. 렌더링 중에 전역 변수를 수정하면 렌더링이 순수하다는 React의 가정을 깨뜨립니다. 이로 인해 컴포넌트가 개발 환경과 프로덕션 환경에서 다르게 동작하거나, Fast Refresh가 중단되거나, React 컴파일러 같은 기능으로 앱을 최적화할 수 없게 됩니다.
1414

15-
### Invalid {/*invalid*/}
15+
### 잘못된 예 {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
이 규칙에 대한 잘못된 코드 예시입니다.
1818

1919
```js
20-
//Global counter
20+
//전역 카운터
2121
let renderCount = 0;
2222
function Component() {
23-
renderCount++; // Mutating global
23+
renderCount++; // 전역 변수 변이
2424
return <div>Count: {renderCount}</div>;
2525
}
2626

27-
//Modifying window properties
27+
// ❌ window 프로퍼티 수정
2828
function Component({userId}) {
29-
window.currentUser = userId; // Global mutation
29+
window.currentUser = userId; // 전역 변이
3030
return <div>User: {userId}</div>;
3131
}
3232

33-
//Global array push
33+
//전역 배열 push
3434
const events = [];
3535
function Component({event}) {
36-
events.push(event); // Mutating global array
36+
events.push(event); // 전역 배열 변이
3737
return <div>Events: {events.length}</div>;
3838
}
3939

40-
//Cache manipulation
40+
//캐시 조작
4141
const cache = {};
4242
function Component({id}) {
4343
if (!cache[id]) {
44-
cache[id] = fetchData(id); // Modifying cache during render
44+
cache[id] = fetchData(id); // 렌더링 중 캐시 수정
4545
}
4646
return <div>{cache[id]}</div>;
4747
}
4848
```
4949

50-
### Valid {/*valid*/}
50+
### 올바른 예 {/*valid*/}
5151

52-
Examples of correct code for this rule:
52+
이 규칙에 대한 올바른 코드 예시입니다.
5353

5454
```js
55-
//Use state for counters
55+
//카운터에는 state 사용
5656
function Component() {
5757
const [clickCount, setClickCount] = useState(0);
5858

@@ -67,16 +67,16 @@ function Component() {
6767
);
6868
}
6969

70-
//Use context for global values
70+
//전역 값에는 context 사용
7171
function Component() {
7272
const user = useContext(UserContext);
7373
return <div>User: {user.id}</div>;
7474
}
7575

76-
//Synchronize external state with React
76+
//외부 state를 React와 동기화
7777
function Component({title}) {
7878
useEffect(() => {
79-
document.title = title; // OK in effect
79+
document.title = title; // Effect 내에서는 OK
8080
}, [title]);
8181

8282
return <div>Page: {title}</div>;

0 commit comments

Comments
 (0)