Skip to content

Commit 4a1ee3e

Browse files
committed
wip
1 parent a6539af commit 4a1ee3e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ title: component-hook-factories
44

55
<Intro>
66

7-
Validates against higher order functions defining nested components or hooks. Components and hooks should be defined at the module level.
7+
중첩된 컴포넌트나 Hook을 정의하는 고차 함수를 검증합니다. 컴포넌트와 Hook은 모듈 레벨에서 정의해야 합니다.
88

99
</Intro>
1010

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

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를 잃고 성능 문제를 일으킵니다.
1414

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

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

1919
```js
20-
//Factory function creating components
20+
//컴포넌트를 생성하는 팩토리 함수
2121
function createComponent(defaultValue) {
2222
return function Component() {
2323
// ...
2424
};
2525
}
2626

27-
//Component defined inside component
27+
//컴포넌트 내부에서 정의된 컴포넌트
2828
function Parent() {
2929
function Child() {
3030
// ...
@@ -33,38 +33,38 @@ function Parent() {
3333
return <Child />;
3434
}
3535

36-
// ❌ Hook factory function
36+
// ❌ Hook 팩토리 함수
3737
function createCustomHook(endpoint) {
3838
return function useData() {
3939
// ...
4040
};
4141
}
4242
```
4343

44-
### Valid {/*valid*/}
44+
### 올바른 예 {/*valid*/}
4545

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

4848
```js
49-
//Component defined at module level
49+
//모듈 레벨에서 정의된 컴포넌트
5050
function Component({ defaultValue }) {
5151
// ...
5252
}
5353

54-
//Custom hook at module level
54+
//모듈 레벨에서 정의된 커스텀 Hook
5555
function useData(endpoint) {
5656
// ...
5757
}
5858
```
5959

60-
## Troubleshooting {/*troubleshooting*/}
60+
## 문제 해결 {/*troubleshooting*/}
6161

62-
### I need dynamic component behavior {/*dynamic-behavior*/}
62+
### 동적 컴포넌트 동작이 필요한 경우 {/*dynamic-behavior*/}
6363

64-
You might think you need a factory to create customized components:
64+
커스터마이즈된 컴포넌트를 만들기 위해 팩토리가 필요하다고 생각할 수 있습니다.
6565

6666
```js
67-
//Wrong: Factory pattern
67+
//잘못된 예: 팩토리 패턴
6868
function makeButton(color) {
6969
return function Button({children}) {
7070
return (
@@ -79,10 +79,10 @@ const RedButton = makeButton('red');
7979
const BlueButton = makeButton('blue');
8080
```
8181

82-
Pass [JSX as children](/learn/passing-props-to-a-component#passing-jsx-as-children) instead:
82+
대신 [JSX를 자식으로 전달](/learn/passing-props-to-a-component#passing-jsx-as-children)하세요.
8383

8484
```js
85-
//Better: Pass JSX as children
85+
//더 나은 방법: JSX를 자식으로 전달
8686
function Button({color, children}) {
8787
return (
8888
<button style={{backgroundColor: color}}>

0 commit comments

Comments
 (0)