Skip to content

Commit 06d7a29

Browse files
authored
Merge branch 'main' into docs-update-incremental-adoption
2 parents 30ce816 + c266e87 commit 06d7a29

File tree

4 files changed

+95
-95
lines changed

4 files changed

+95
-95
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ title: exhaustive-deps
44

55
<Intro>
66

7-
Validates that dependency arrays for React hooks contain all necessary dependencies.
7+
React Hook의 의존성 배열에 필요한 모든 의존성이 포함되어 있는지 검증합니다.
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## 규칙 자세히보기 {/*rule-details*/}
1212

13-
React hooks like `useEffect`, `useMemo`, and `useCallback` accept dependency arrays. When a value referenced inside these hooks isn't included in the dependency array, React won't re-run the effect or recalculate the value when that dependency changes. This causes stale closures where the hook uses outdated values.
13+
`useEffect`, `useMemo`, `useCallback`과 같은 React Hook은 의존성 배열을 받습니다. 이 Hook들 안에서 참조한 값이 의존성 배열에 포함되지 않으면 그 값이 바뀌어도 React가 effect를 다시 실행하거나 값을 다시 계산하지 않습니다. 그 결과 Hook이 예전 값을 계속 붙잡고 사용하는 "stale closure(오래된 클로저)" 문제가 생겨 최신 값이 아닌 상태로 동작하게 됩니다.
1414

15-
## Common Violations {/*common-violations*/}
15+
## 흔한 위반 사항 {/*common-violations*/}
1616

17-
This error often happens when you try to "trick" React about dependencies to control when an effect runs. Effects should synchronize your component with external systems. The dependency array tells React which values the effect uses, so React knows when to re-synchronize.
17+
이 오류는 effect 실행 시점을 조절하려고 의존성을 의도적으로 누락할 때 자주 발생합니다. Effect는 컴포넌트를 외부 시스템과 동기화하기 위한 용도여야 합니다. 의존성 배열은 effect가 어떤 값을 사용하고 있는지 React에게 알려주며, React는 이를 바탕으로 언제 다시 동기화해야 하는지 판단합니다.
1818

19-
If you find yourself fighting with the linter, you likely need to restructure your code. See [Removing Effect Dependencies](/learn/removing-effect-dependencies) to learn how.
19+
린터 경고를 계속 피하려고 하거나 맞추기 어렵다고 느낀다면, 코드 구조를 다시 구성해야 할 가능성이 큽니다. 방법은 [Effect의 의존성 제거하기](/learn/removing-effect-dependencies) 문서를 참고하세요.
2020

21-
### Invalid {/*invalid*/}
21+
### 유효하지 않음 {/*invalid*/}
2222

23-
Examples of incorrect code for this rule:
23+
이 규칙에 대한 잘못된 코드 예시
2424

2525
```js
2626
// ❌ Missing dependency
@@ -39,9 +39,9 @@ useMemo(() => {
3939
}, [items]); // Missing 'sortOrder'
4040
```
4141

42-
### Valid {/*valid*/}
42+
### 유효 {/*valid*/}
4343

44-
Examples of correct code for this rule:
44+
이 규칙에 대한 올바른 예시
4545

4646
```js
4747
// ✅ All dependencies included
@@ -55,11 +55,11 @@ useEffect(() => {
5555
}, [userId]);
5656
```
5757

58-
## Troubleshooting {/*troubleshooting*/}
58+
## 문제 해결 {/*troubleshooting*/}
5959

60-
### Adding a function dependency causes infinite loops {/*function-dependency-loops*/}
60+
### 함수를 의존성으로 추가하면 무한 루프가 발생할 수 있습니다 {/*function-dependency-loops*/}
6161

62-
You have an effect, but you're creating a new function on every render:
62+
effect를 사용하고 있지만, 렌더링이 일어날 때마다 새로운 함수를 매번 생성하고 있습니다.
6363

6464
```js
6565
// ❌ Causes infinite loop
@@ -72,7 +72,7 @@ useEffect(() => {
7272
}, [logItems]); // Infinite loop!
7373
```
7474

75-
In most cases, you don't need the effect. Call the function where the action happens instead:
75+
대부분의 경우 effect는 필요하지 않습니다. 대신 그 동작이 실제로 발생하는 지점에서 함수를 호출하세요.
7676

7777
```js
7878
// ✅ Call it from the event handler
@@ -88,7 +88,7 @@ items.forEach(item => {
8888
});
8989
```
9090

91-
If you genuinely need the effect (for example, to subscribe to something external), make the dependency stable:
91+
정말로 effect가 필요한 경우(예: 외부 무언가를 구독해야 하는 경우)에는, 의존성이 안정적이도록 만드세요.
9292

9393
```js
9494
// ✅ useCallback keeps the function reference stable
@@ -106,9 +106,9 @@ useEffect(() => {
106106
}, [items]);
107107
```
108108

109-
### Running an effect only once {/*effect-on-mount*/}
109+
### effect를 한 번만 실행하기 {/*effect-on-mount*/}
110110

111-
You want to run an effect once on mount, but the linter complains about missing dependencies:
111+
마운트 시점에 effect를 한 번만 실행하고 싶지만, 린터가 누락된 의존성에 대해 경고합니다.
112112

113113
```js
114114
// ❌ Missing dependency
@@ -117,7 +117,7 @@ useEffect(() => {
117117
}, []); // Missing 'userId'
118118
```
119119

120-
Either include the dependency (recommended) or use a ref if you truly need to run once:
120+
의존성을 포함하는 것이 권장되며, 정말로 한 번만 실행해야 한다면 Ref를 사용하세요.
121121

122122
```js
123123
// ✅ Include dependency
@@ -138,9 +138,9 @@ useEffect(() => {
138138
}, [userId]);
139139
```
140140

141-
## Options {/*options*/}
141+
## 옵션 {/*options*/}
142142

143-
You can configure custom effect hooks using shared ESLint settings (available in `eslint-plugin-react-hooks` 6.1.1 and later):
143+
공유 ESLint 설정을 사용해 커스텀 Effect Hook을 설정할 수 있습니다(`eslint-plugin-react-hooks` 6.1.1 이상에서 지원).
144144

145145
```js
146146
{
@@ -152,9 +152,9 @@ You can configure custom effect hooks using shared ESLint settings (available in
152152
}
153153
```
154154

155-
- `additionalEffectHooks`: Regex pattern matching custom hooks that should be checked for exhaustive dependencies. This configuration is shared across all `react-hooks` rules.
155+
- `additionalEffectHooks`: 철저한 의존성 검사를 적용해야 하는 커스텀 Hook을 정규식 패턴으로 지정합니다. 이 설정은 모든 `react-hooks` 규칙에서 공통으로 사용됩니다.
156156

157-
For backward compatibility, this rule also accepts a rule-level option:
157+
하위 호환성을 위해 이 규칙은 규칙 단위 옵션도 함께 지원합니다.
158158

159159
```js
160160
{
@@ -166,4 +166,4 @@ For backward compatibility, this rule also accepts a rule-level option:
166166
}
167167
```
168168

169-
- `additionalHooks`: Regex for hooks that should be checked for exhaustive dependencies. **Note:** If this rule-level option is specified, it takes precedence over the shared `settings` configuration.
169+
- `additionalHooks`: 빠짐없는 의존성 검사(exhaustive deps)를 적용해야 하는 Hook을 정규식으로 지정합니다. **참고:** 이 규칙별 옵션을 지정하면 공유 `settings` 설정보다 우선 적용됩니다.
Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: Directives
2+
title: 지시어
33
---
44

55
<Intro>
6-
React Compiler directives are special string literals that control whether specific functions are compiled.
6+
React 컴파일러 지시어는 특정 함수에 대한 컴파일 적용 여부를 제어하는 특수 문자열 리터럴입니다.
77
</Intro>
88

99
```js
1010
function MyComponent() {
11-
"use memo"; // Opt this component into compilation
11+
"use memo"; // 이 컴포넌트를 컴파일 대상으로 설정합니다
1212
return <div>{/* ... */}</div>;
1313
}
1414
```
@@ -17,53 +17,53 @@ function MyComponent() {
1717

1818
---
1919

20-
## Overview {/*overview*/}
20+
## 개요 {/*overview*/}
2121

22-
React Compiler directives provide fine-grained control over which functions are optimized by the compiler. They are string literals placed at the beginning of a function body or at the top of a module.
22+
React 컴파일러 지시어는 컴파일러가 최적화할 함수를 세밀하게 제어할 수 있도록 합니다. 함수 본문의 시작 부분이나 모듈의 최상단에 배치되는 문자열 리터럴입니다.
2323

24-
### Available directives {/*available-directives*/}
24+
### 사용 가능한 지시어 {/*available-directives*/}
2525

26-
* **[`"use memo"`](/reference/react-compiler/directives/use-memo)** - Opts a function into compilation
27-
* **[`"use no memo"`](/reference/react-compiler/directives/use-no-memo)** - Opts a function out of compilation
26+
* **[`"use memo"`](/reference/react-compiler/directives/use-memo)** - 함수를 컴파일 대상으로 선택합니다
27+
* **[`"use no memo"`](/reference/react-compiler/directives/use-no-memo)** - 함수를 컴파일 대상에서 제외합니다
2828

29-
### Quick comparison {/*quick-comparison*/}
29+
### 빠른 비교 {/*quick-comparison*/}
3030

31-
| Directive | Purpose | When to use |
31+
| 지시어 | 목적 | 사용 시점 |
3232
|-----------|---------|-------------|
33-
| [`"use memo"`](/reference/react-compiler/directives/use-memo) | Force compilation | When using `annotation` mode or to override `infer` mode heuristics |
34-
| [`"use no memo"`](/reference/react-compiler/directives/use-no-memo) | Prevent compilation | Debugging issues or working with incompatible code |
33+
| [`"use memo"`](/reference/react-compiler/directives/use-memo) | 컴파일 강제 | `annotation` 모드를 사용하거나 `infer` 모드의 휴리스틱을 재정의할 때 |
34+
| [`"use no memo"`](/reference/react-compiler/directives/use-no-memo) | 컴파일 제외 | 이슈를 디버깅하거나 호환되지 않는 코드를 다룰 때 |
3535

3636
---
3737

38-
## Usage {/*usage*/}
38+
## 사용법 {/*usage*/}
3939

40-
### Function-level directives {/*function-level*/}
40+
### 함수 수준 지시어 {/*function-level*/}
4141

42-
Place directives at the beginning of a function to control its compilation:
42+
함수의 시작 부분에 지시어를 선언하여 컴파일을 제어합니다.
4343

4444
```js
45-
// Opt into compilation
45+
// 컴파일 대상으로 설정
4646
function OptimizedComponent() {
4747
"use memo";
4848
return <div>This will be optimized</div>;
4949
}
5050

51-
// Opt out of compilation
51+
// 컴파일 대상에서 제외
5252
function UnoptimizedComponent() {
5353
"use no memo";
5454
return <div>This won't be optimized</div>;
5555
}
5656
```
5757
58-
### Module-level directives {/*module-level*/}
58+
### 모듈 수준 지시어 {/*module-level*/}
5959
60-
Place directives at the top of a file to affect all functions in that module:
60+
파일의 최상단에 선언하여 해당 모듈의 모든 함수에 적용됩니다.
6161
6262
```js
63-
// At the very top of the file
63+
// 파일의 최상단에 선언
6464
"use memo";
6565
66-
// All functions in this file will be compiled
66+
// 이 파일의 모든 함수가 컴파일됩니다
6767
function Component1() {
6868
return <div>Compiled</div>;
6969
}
@@ -72,31 +72,31 @@ function Component2() {
7272
return <div>Also compiled</div>;
7373
}
7474
75-
// Can be overridden at function level
75+
// 함수 수준에서 재정의 가능
7676
function Component3() {
77-
"use no memo"; // This overrides the module directive
77+
"use no memo"; // 모듈 수준에서 재정의됩니다
7878
return <div>Not compiled</div>;
7979
}
8080
```
8181
82-
### Compilation modes interaction {/*compilation-modes*/}
82+
### 컴파일 모드와의 상호작용 {/*compilation-modes*/}
8383
84-
Directives behave differently depending on your [`compilationMode`](/reference/react-compiler/compilationMode):
84+
지시어는 [`compilationMode`](/reference/react-compiler/compilationMode)에 따라 다르게 동작합니다.
8585
86-
* **`annotation` mode**: Only functions with `"use memo"` are compiled
87-
* **`infer` mode**: Compiler decides what to compile, directives override decisions
88-
* **`all` mode**: Everything is compiled, `"use no memo"` can exclude specific functions
86+
* **`annotation` 모드**: `"use memo"`가 선언된 함수만 컴파일됩니다
87+
* **`infer` 모드**: 컴파일러가 컴파일할 대상을 결정하며 지시어는 이 결정을 재정의합니다
88+
* **`all` 모드**: 모든 것이 컴파일되며 `"use no memo"` 로 특정 함수를 제외할 수 있습니다
8989
9090
---
9191
92-
## Best practices {/*best-practices*/}
92+
## 모범 사례 {/*best-practices*/}
9393
94-
### Use directives sparingly {/*use-sparingly*/}
94+
### 지시어는 신중하게 사용하세요 {/*use-sparingly*/}
9595
96-
Directives are escape hatches. Prefer configuring the compiler at the project level:
96+
이 지시어는 탈출구(escape hatch)입니다. 컴파일러는 프로젝트 수준에서 설정하는 것을 권장합니다.
9797
9898
```js
99-
// ✅ Good - project-wide configuration
99+
// ✅ good - 프로젝트 전역 설정
100100
{
101101
plugins: [
102102
['babel-plugin-react-compiler', {
@@ -105,94 +105,94 @@ Directives are escape hatches. Prefer configuring the compiler at the project le
105105
]
106106
}
107107
108-
// ⚠️ Use directives only when needed
108+
// ⚠️ 필요할 때마 지시어 사용
109109
function SpecialCase() {
110-
"use no memo"; // Document why this is needed
110+
"use no memo"; // 왜 필요한지 문서화하세요
111111
// ...
112112
}
113113
```
114114
115-
### Document directive usage {/*document-usage*/}
115+
### 지시어 사용 이유를 문서화하세요 {/*document-usage*/}
116116
117-
Always explain why a directive is used:
117+
지시어를 사용하는 이유를 항상 명확히 설명하세요.
118118
119119
```js
120-
// ✅ Good - clear explanation
120+
// ✅ good - 명확한 설명
121121
function DataGrid() {
122-
"use no memo"; // TODO: Remove after fixing issue with dynamic row heights (JIRA-123)
123-
// Complex grid implementation
122+
"use no memo"; // TODO: 동적 row heiht 이슈 해결 후 제거 (JIRA-123)
123+
// 복잡한 그리드 구현
124124
}
125125
126-
// ❌ Bad - no explanation
126+
// ❌ bad - 설명 없음
127127
function Mystery() {
128128
"use no memo";
129129
// ...
130130
}
131131
```
132132
133-
### Plan for removal {/*plan-removal*/}
133+
### 제거 계획을 세우세요 {/*plan-removal*/}
134134
135-
Opt-out directives should be temporary:
135+
제외 지시어는 임시로 사용해야 합니다.
136136
137-
1. Add the directive with a TODO comment
138-
2. Create a tracking issue
139-
3. Fix the underlying problem
140-
4. Remove the directive
137+
1. TODO 주석과 함께 지시어를 추가합니다
138+
2. 추적용 이슈를 생성합니다
139+
3. 근본적인 문제를 해결합니다
140+
4. 지시어를 제거합니다
141141
142142
```js
143143
function TemporaryWorkaround() {
144-
"use no memo"; // TODO: Remove after upgrading ThirdPartyLib to v2.0
144+
"use no memo"; // TODO: ThirdPartyLib를 v2.0으로 업그레이드한 후 제거
145145
return <ThirdPartyComponent />;
146146
}
147147
```
148148
149149
---
150150
151-
## Common patterns {/*common-patterns*/}
151+
## 일반적인 패턴 {/*common-patterns*/}
152152
153-
### Gradual adoption {/*gradual-adoption*/}
153+
### 점진적 도입 {/*gradual-adoption*/}
154154
155-
When adopting the React Compiler in a large codebase:
155+
대규모 코드베이스에서 React 컴파일러를 도입할 때 다음과 같은 방식이 일반적입니다.
156156
157157
```js
158-
// Start with annotation mode
158+
// annotation 모드로 시작
159159
{
160160
compilationMode: 'annotation'
161161
}
162162
163-
// Opt in stable components
163+
// 안정적인 컴파일러를 컴파일 대상으로 설정
164164
function StableComponent() {
165165
"use memo";
166-
// Well-tested component
166+
// 충분히 테스트된 컴포넌트
167167
}
168168
169-
// Later, switch to infer mode and opt out problematic ones
169+
// 나중에 infer 모드로 전환하고 문제가 있는 컴포넌트는 제외
170170
function ProblematicComponent() {
171-
"use no memo"; // Fix issues before removing
171+
"use no memo"; // 제거 전에 이슈를 해결하세요
172172
// ...
173173
}
174174
```
175175
176176
177177
---
178178
179-
## Troubleshooting {/*troubleshooting*/}
179+
## 문제 해결 {/*troubleshooting*/}
180180
181-
For specific issues with directives, see the troubleshooting sections in:
181+
지시어와 관련된 구체적인 문제는 다음 문제 해결 섹션을 참고하세요.
182182
183-
* [`"use memo"` troubleshooting](/reference/react-compiler/directives/use-memo#troubleshooting)
184-
* [`"use no memo"` troubleshooting](/reference/react-compiler/directives/use-no-memo#troubleshooting)
183+
* [`"use memo"` 문제 해결](/reference/react-compiler/directives/use-memo#troubleshooting)
184+
* [`"use no memo"` 문제 해결](/reference/react-compiler/directives/use-no-memo#troubleshooting)
185185
186-
### Common issues {/*common-issues*/}
186+
### 자주 발생하는 이슈 {/*common-issues*/}
187187
188-
1. **Directive ignored**: Check placement (must be first) and spelling
189-
2. **Compilation still happens**: Check `ignoreUseNoForget` setting
190-
3. **Module directive not working**: Ensure it's before all imports
188+
1. **지시어가 무시됨**: 위치(파일 또는 함수의 첫 줄인지)와 철자를 확인하세요.
189+
2. **컴파일이 계속됨**: `ignoreUseNoForget` 설정을 확인하세요.
190+
3. **모듈 수준 지시어가 작동하지 않음**: 모든 import 문보다 앞에 있는지 확인하세요.
191191
192192
---
193193
194-
## See also {/*see-also*/}
194+
## 참고 {/*see-also*/}
195195
196-
* [`compilationMode`](/reference/react-compiler/compilationMode) - Configure how the compiler chooses what to optimize
197-
* [`Configuration`](/reference/react-compiler/configuration) - Full compiler configuration options
198-
* [React Compiler documentation](https://react.dev/learn/react-compiler) - Getting started guide
196+
* [`compilationMode`](/reference/react-compiler/compilationMode) - 컴파일러가 최적화 대상을 선택하는 방식을 설정합니다
197+
* [`Configuration`](/reference/react-compiler/configuration) - 전체 컴파일러 설정 옵션
198+
* [React Compiler documentation](https://react.dev/learn/react-compiler) - 시작 가이드

0 commit comments

Comments
 (0)