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/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