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/eslint-plugin-react-hooks/index.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,36 +5,36 @@ version: rc
5
5
6
6
<Intro>
7
7
8
-
`eslint-plugin-react-hooks` provides ESLint rules to enforce the [Rules of React](/reference/rules).
8
+
`eslint-plugin-react-hooks`는 [React의 규칙](/reference/rules)을 적용하기 위한 ESLint 규칙을 제공합니다.
9
9
10
10
</Intro>
11
11
12
-
This plugin helps you catch violations of React's rules at build time, ensuring your components and hooks follow React's rules for correctness and performance. The lints cover both fundamental React patterns (exhaustive-deps and rules-of-hooks) and issues flagged by React Compiler. React Compiler diagnostics are automatically surfaced by this ESLint plugin, and can be used even if your app hasn't adopted the compiler yet.
12
+
이 플러그인은 빌드 시간에 React 규칙 위반을 감지하여 컴포넌트와 Hook이 정확성과 성능을 위한 React 규칙을 따르도록 도와줍니다. 린트는 기본적인 React 패턴(`exhaustive-deps` 및 `rules-of-hooks`)과 React 컴파일러가 표시하는 문제를 모두 다룹니다. React 컴파일러 진단은 ESLint 플러그인에 의해 자동으로 표시되며, 앱이 아직 컴파일러를 도입하지 않았더라도 사용할 수 있습니다.
13
13
14
14
<Note>
15
-
When the compiler reports a diagnostic, it means that the compiler was able to statically detect a pattern that is not supported or breaks the Rules of React. When it detects this, it**automatically**skips over those components and hooks, while keeping the rest of your app compiled. This ensures optimal coverage of safe optimizations that won't break your app.
15
+
컴파일러가 진단을 보고하면 컴파일러가 지원되지 않거나 React 규칙을 위반하는 패턴을 정적으로 감지했다는 것을 의미합니다. 이를 감지하면 해당 컴포넌트와 Hook을**자동으로**건너뛰고 나머지 앱은 계속 컴파일합니다. 이렇게 하면 앱을 손상시키지 않는 안전한 최적화의 최적 적용 범위를 보장합니다.
16
16
17
-
What this means for linting, is that you don’t need to fix all violations immediately. Address them at your own pace to gradually increase the number of optimized components.
17
+
린트에서 이것이 의미하는 바는 모든 위반을 즉시 수정할 필요가 없다는 것입니다. 자신의 속도에 맞춰 해결하여 점진적으로 최적화된 컴포넌트 수를 늘리세요.
18
18
</Note>
19
19
20
-
## Recommended Rules {/*recommended*/}
21
-
22
-
These rules are included in the `recommended` preset in `eslint-plugin-react-hooks`:
23
-
24
-
*[`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - Validates that dependency arrays for React hooks contain all necessary dependencies
25
-
*[`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - Validates that components and hooks follow the Rules of Hooks
26
-
*[`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - Validates higher order functions defining nested components or hooks
27
-
*[`config`](/reference/eslint-plugin-react-hooks/lints/config) - Validates the compiler configuration options
28
-
*[`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) - Validates usage of Error Boundaries instead of try/catch for child errors
29
-
*[`gating`](/reference/eslint-plugin-react-hooks/lints/gating) - Validates configuration of gating mode
30
-
*[`globals`](/reference/eslint-plugin-react-hooks/lints/globals) - Validates against assignment/mutation of globals during render
31
-
*[`immutability`](/reference/eslint-plugin-react-hooks/lints/immutability) - Validates against mutating props, state, and other immutable values
32
-
*[`incompatible-library`](/reference/eslint-plugin-react-hooks/lints/incompatible-library) - Validates against usage of libraries which are incompatible with memoization
33
-
*[`preserve-manual-memoization`](/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization) - Validates that existing manual memoization is preserved by the compiler
34
-
*[`purity`](/reference/eslint-plugin-react-hooks/lints/purity) - Validates that components/hooks are pure by checking known-impure functions
35
-
*[`refs`](/reference/eslint-plugin-react-hooks/lints/refs) - Validates correct usage of refs, not reading/writing during render
36
-
*[`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect) - Validates against calling setState synchronously in an effect
37
-
*[`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render) - Validates against setting state during render
38
-
*[`static-components`](/reference/eslint-plugin-react-hooks/lints/static-components) - Validates that components are static, not recreated every render
39
-
*[`unsupported-syntax`](/reference/eslint-plugin-react-hooks/lints/unsupported-syntax) - Validates against syntax that React Compiler does not support
40
-
*[`use-memo`](/reference/eslint-plugin-react-hooks/lints/use-memo) - Validates usage of the `useMemo`hook without a return value
20
+
## 권장<sup>Recommended</sup> 규칙 {/*recommended*/}
21
+
22
+
아래 규칙들은 `eslint-plugin-react-hooks`의 `recommended` 프리셋에 포함되어 있습니다.
23
+
24
+
*[`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - React Hook의 의존성 배열에 필요한 모든 의존성이 포함되어 있는지 검증합니다.
25
+
*[`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - 컴포넌트와 Hook이 Hook의 규칙을 따르는지 검증합니다.
26
+
*[`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - 중첩된 컴포넌트나 Hook을 정의하는 고차 함수를 검증합니다.
27
+
*[`config`](/reference/eslint-plugin-react-hooks/lints/config) - 컴파일러 설정 옵션을 검증합니다.
28
+
*[`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) - 자식 오류에 대해 try/catch 대신 Error Boundary 사용을 검증합니다.
29
+
*[`gating`](/reference/eslint-plugin-react-hooks/lints/gating) - 게이팅 모드 설정을 검증합니다.
30
+
*[`globals`](/reference/eslint-plugin-react-hooks/lints/globals) - 렌더링 중 전역 변수의 할당/변이를 검증합니다.
31
+
*[`immutability`](/reference/eslint-plugin-react-hooks/lints/immutability) - props, state 및 기타 불변 값의 변이를 검증합니다.
32
+
*[`incompatible-library`](/reference/eslint-plugin-react-hooks/lints/incompatible-library) - 메모이제이션과 호환되지 않는 라이브러리 사용을 검증합니다.
33
+
*[`preserve-manual-memoization`](/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization) - 기존의 수동 메모이제이션이 컴파일러에 의해 유지되는지 검증합니다.
34
+
*[`purity`](/reference/eslint-plugin-react-hooks/lints/purity) - 알려진 불순 함수를 확인하여 컴포넌트/Hook이 순수한지 검증합니다.
35
+
*[`refs`](/reference/eslint-plugin-react-hooks/lints/refs) - 렌더링 중 읽기/쓰기가 아닌 ref의 올바른 사용을 검증합니다.
36
+
*[`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect) - Effect에서 `setState`를 동기적으로 호출하는 것을 검증합니다.
37
+
*[`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render) - 렌더링 중 state 설정을 검증합니다.
38
+
*[`static-components`](/reference/eslint-plugin-react-hooks/lints/static-components) - 컴포넌트가 매 렌더링마다 재생성되지 않고 정적인지 검증합니다.
39
+
*[`unsupported-syntax`](/reference/eslint-plugin-react-hooks/lints/unsupported-syntax) - React 컴파일러가 지원하지 않는 문법을 검증합니다.
40
+
*[`use-memo`](/reference/eslint-plugin-react-hooks/lints/use-memo) - 반환값 없이 `useMemo`Hook을 사용하는 것을 검증합니다.
Copy file name to clipboardExpand all lines: src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,27 @@ title: component-hook-factories
4
4
5
5
<Intro>
6
6
7
-
Validates against higher order functions defining nested components or hooks. Components and hooks should be defined at the module level.
7
+
중첩된 컴포넌트나 Hook을 정의하는 고차 함수를 검증합니다. 컴포넌트와 Hook은 모듈 레벨에서 정의해야 합니다.
8
8
9
9
</Intro>
10
10
11
-
## Rule Details {/*rule-details*/}
11
+
## 규칙 세부 사항 {/*rule-details*/}
12
12
13
-
Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems.
13
+
다른 함수 내부에서 컴포넌트나 Hook을 정의하면 호출할 때마다 새로운 인스턴스가 생성됩니다. React는 각각을 완전히 다른 컴포넌트로 취급하여 전체 컴포넌트 트리를 파괴하고 다시 생성하며, 모든 state를 잃고 성능 문제를 일으킵니다.
14
14
15
-
### Invalid {/*invalid*/}
15
+
### 잘못된 예시 {/*invalid*/}
16
16
17
-
Examples of incorrect code for this rule:
17
+
이 규칙에 대한 잘못된 코드 예시입니다.
18
18
19
19
```js
20
-
// ❌ Factory function creating components
20
+
// ❌ 컴포넌트를 생성하는 팩토리 함수
21
21
functioncreateComponent(defaultValue) {
22
22
returnfunctionComponent() {
23
23
// ...
24
24
};
25
25
}
26
26
27
-
// ❌ Component defined inside component
27
+
// ❌ 컴포넌트 내부에서 정의된 컴포넌트
28
28
functionParent() {
29
29
functionChild() {
30
30
// ...
@@ -33,38 +33,38 @@ function Parent() {
33
33
return<Child />;
34
34
}
35
35
36
-
// ❌ Hook factory function
36
+
// ❌ Hook 팩토리 함수
37
37
functioncreateCustomHook(endpoint) {
38
38
returnfunctionuseData() {
39
39
// ...
40
40
};
41
41
}
42
42
```
43
43
44
-
### Valid {/*valid*/}
44
+
### 올바른 예시 {/*valid*/}
45
45
46
-
Examples of correct code for this rule:
46
+
이 규칙에 대한 올바른 코드 예시입니다.
47
47
48
48
```js
49
-
// ✅ Component defined at module level
49
+
// ✅ 모듈 레벨에서 정의된 컴포넌트
50
50
functionComponent({ defaultValue }) {
51
51
// ...
52
52
}
53
53
54
-
// ✅ Custom hook at module level
54
+
// ✅ 모듈 레벨에서 정의된 커스텀 Hook
55
55
functionuseData(endpoint) {
56
56
// ...
57
57
}
58
58
```
59
59
60
-
## Troubleshooting {/*troubleshooting*/}
60
+
## 문제 해결 {/*troubleshooting*/}
61
61
62
-
### I need dynamic component behavior {/*dynamic-behavior*/}
62
+
### 동적 컴포넌트 동작이 필요한 경우 {/*dynamic-behavior*/}
63
63
64
-
You might think you need a factory to create customized components:
React Compiler accepts various [configuration options](/reference/react-compiler/configuration) to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings.
13
+
React 컴파일러는 동작을 제어하기 위해 다양한 [설정 옵션](/reference/react-compiler/configuration)을 받습니다. 이 규칙은 설정이 올바른 옵션 이름과 값 타입을 사용하는지 검증하여 오타나 잘못된 설정으로 인한 무시되는 오류를 방지합니다.
14
14
15
-
### Invalid {/*invalid*/}
15
+
### 잘못된 예시 {/*invalid*/}
16
16
17
-
Examples of incorrect code for this rule:
17
+
이 규칙에 대한 잘못된 코드 예시입니다.
18
18
19
19
```js
20
-
// ❌ Unknown option name
20
+
// ❌ 알 수 없는 옵션 이름
21
21
module.exports= {
22
22
plugins: [
23
23
['babel-plugin-react-compiler', {
24
-
compileMode:'all'//Typo: should be compilationMode
24
+
compileMode:'all'//오타: compilationMode여야 함
25
25
}]
26
26
]
27
27
};
28
28
29
-
// ❌ Invalid option value
29
+
// ❌ 유효하지 않은 옵션 값
30
30
module.exports= {
31
31
plugins: [
32
32
['babel-plugin-react-compiler', {
33
-
compilationMode:'everything'//Invalid: use 'all' or 'infer'
33
+
compilationMode:'everything'//유효하지 않음: 'all' 또는 'infer'를 사용하세요
34
34
}]
35
35
]
36
36
};
37
37
```
38
38
39
-
### Valid {/*valid*/}
39
+
### 올바른 예시 {/*valid*/}
40
40
41
-
Examples of correct code for this rule:
41
+
이 규칙에 대한 올바른 코드 예시입니다.
42
42
43
43
```js
44
-
// ✅ Valid compiler configuration
44
+
// ✅ 유효한 컴파일러 설정
45
45
module.exports= {
46
46
plugins: [
47
47
['babel-plugin-react-compiler', {
@@ -52,38 +52,38 @@ module.exports = {
52
52
};
53
53
```
54
54
55
-
## Troubleshooting {/*troubleshooting*/}
55
+
## 문제 해결 {/*troubleshooting*/}
56
56
57
-
### Configuration not working as expected {/*config-not-working*/}
57
+
### 설정이 예상대로 작동하지 않는 경우 {/*config-not-working*/}
58
58
59
-
Your compiler configuration might have typos or incorrect values:
59
+
컴파일러 설정에 오타나 잘못된 값이 있을 수 있습니다.
60
60
61
61
```js
62
-
// ❌ Wrong: Common configuration mistakes
62
+
// ❌ 잘못된 예: 일반적인 설정 실수
63
63
module.exports= {
64
64
plugins: [
65
65
['babel-plugin-react-compiler', {
66
-
//Typo in option name
66
+
//옵션 이름 오타
67
67
compilationMod:'all',
68
-
//Wrong value type
68
+
//잘못된 값 타입
69
69
panicThreshold:true,
70
-
//Unknown option
70
+
//알 수 없는 옵션
71
71
optimizationLevel:'max'
72
72
}]
73
73
]
74
74
};
75
75
```
76
76
77
-
Check the [configuration documentation](/reference/react-compiler/configuration) for valid options:
Copy file name to clipboardExpand all lines: src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,35 +4,35 @@ title: error-boundaries
4
4
5
5
<Intro>
6
6
7
-
Validates usage of Error Boundaries instead of try/catch for errors in child components.
7
+
자식 컴포넌트의 오류에 대해 `try`/`catch` 대신 Error Boundary 사용을 검증합니다.
8
8
9
9
</Intro>
10
10
11
-
## Rule Details {/*rule-details*/}
11
+
## 규칙 세부 사항 {/*rule-details*/}
12
12
13
-
Try/catch blocks can't catch errors that happen during React's rendering process. Errors thrown in rendering methods or hooks bubble up through the component tree. Only[Error Boundaries](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) can catch these errors.
13
+
`try`/`catch` 블록은 React의 렌더링 과정에서 발생하는 오류를 잡을 수 없습니다. 렌더링 메서드나 Hook에서 발생한 오류는 컴포넌트 트리를 타고 위로 전파됩니다. 오직[Error Boundary](/reference/react/Component#catching-rendering-errors-with-an-error-boundary)만이 이러한 오류를 잡을 수 있습니다.
14
14
15
-
### Invalid {/*invalid*/}
15
+
### 잘못된 예시 {/*invalid*/}
16
16
17
-
Examples of incorrect code for this rule:
17
+
이 규칙에 대한 잘못된 코드 예시입니다.
18
18
19
19
```js
20
-
// ❌ Try/catch won't catch render errors
20
+
// ❌ `try`/`catch`는 렌더링 오류를 잡을 수 없음
21
21
functionParent() {
22
22
try {
23
-
return<ChildComponent />; //If this throws, catch won't help
23
+
return<ChildComponent />; //여기서 오류가 발생하면 catch가 도움이 되지 않음
24
24
} catch (error) {
25
25
return<div>Error occurred</div>;
26
26
}
27
27
}
28
28
```
29
29
30
-
### Valid {/*valid*/}
30
+
### 올바른 예시 {/*valid*/}
31
31
32
-
Examples of correct code for this rule:
32
+
이 규칙에 대한 올바른 코드 예시입니다.
33
33
34
34
```js
35
-
// ✅ Using error boundary
35
+
// ✅ Error Boundary 사용
36
36
functionParent() {
37
37
return (
38
38
<ErrorBoundary>
@@ -42,24 +42,24 @@ function Parent() {
42
42
}
43
43
```
44
44
45
-
## Troubleshooting {/*troubleshooting*/}
45
+
## 문제 해결 {/*troubleshooting*/}
46
46
47
-
### Why is the linter telling me not to wrap `use` in `try`/`catch`? {/*why-is-the-linter-telling-me-not-to-wrap-use-in-trycatch*/}
47
+
### 린터가 `use`를 `try`/`catch`로 감싸지 말라고 하는 이유는 무엇인가요? {/*why-is-the-linter-telling-me-not-to-wrap-use-in-trycatch*/}
48
48
49
-
The `use`hook doesn't throw errors in the traditional sense, it suspends component execution. When `use` encounters a pending promise, it suspends the component and lets React show a fallback. Only Suspense and Error Boundaries can handle these cases. The linter warns against `try`/`catch`around `use` to prevent confusion as the `catch` block would never run.
49
+
`use`Hook은 전통적인 의미에서 오류를 던지지 않고 컴포넌트 실행을 일시 중단합니다. `use`가 대기 중인 Promise를 만나면 컴포넌트를 일시 중단하고 React가 폴백을 표시하도록 합니다. Suspense와 Error Boundary만이 이러한 경우를 처리할 수 있습니다. 린터는 `catch`블록이 절대 실행되지 않으므로 혼란을 방지하기 위해 `use` 주위의 `try`/`catch`에 대해 경고합니다.
50
50
51
51
```js
52
-
// ❌ Try/catch around `use` hook
52
+
// ❌ `use` Hook 주위의 try/catch
53
53
functionComponent({promise}) {
54
54
try {
55
-
constdata=use(promise); //Won't catch - `use` suspends, not throws
55
+
constdata=use(promise); //잡을 수 없음 - `use`는 던지지 않고 일시 중단함
56
56
return<div>{data}</div>;
57
57
} catch (error) {
58
-
return<div>Failed to load</div>; //Unreachable
58
+
return<div>Failed to load</div>; //도달 불가
59
59
}
60
60
}
61
61
62
-
// ✅ Error boundary catches `use` errors
62
+
// ✅ Error Boundary가 `use` 오류를 잡음
63
63
functionApp() {
64
64
return (
65
65
<ErrorBoundary fallback={<div>Failed to load</div>}>
0 commit comments