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/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:
0 commit comments