Skip to content

Commit 96d7892

Browse files
committed
wip
1 parent fa8fc5e commit 96d7892

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/content/reference/eslint-plugin-react-hooks/lints/incompatible-library.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,59 @@ title: incompatible-library
44

55
<Intro>
66

7-
Validates against usage of libraries which are incompatible with memoization (manual or automatic).
7+
메모이제이션(수동 또는 자동)과 호환되지 않는 라이브러리 사용에 대해 검증합니다.
88

99
</Intro>
1010

1111
<Note>
1212

13-
These libraries were designed before React's memoization rules were fully documented. They made the correct choices at the time to optimize for ergonomic ways to keep components just the right amount of reactive as app state changes. While these legacy patterns worked, we have since discovered that it's incompatible with React's programming model. We will continue working with library authors to migrate these libraries to use patterns that follow the Rules of React.
13+
이러한 라이브러리는 React의 메모이제이션 규칙이 완전히 문서화되기 전에 설계되었습니다. 당시에는 앱 상태가 변경될 때 컴포넌트가 적절한 반응성을 유지하도록 인체공학적인 방법을 최적화하기 위해 올바른 선택을 했습니다. 이러한 레거시 패턴은 작동했지만, 이후 React의 프로그래밍 모델과 호환되지 않는다는 것을 발견했습니다. React 규칙을 따르는 패턴을 사용하도록 이러한 라이브러리를 마이그레이션하기 위해 라이브러리 작성자와 계속 협력하고 있습니다.
1414

1515
</Note>
1616

17-
## Rule Details {/*rule-details*/}
17+
## 규칙 세부 정보 {/*rule-details*/}
1818

19-
Some libraries use patterns that aren't supported by React. When the linter detects usages of these APIs from a [known list](https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts), it flags them under this rule. This means that React Compiler can automatically skip over components that use these incompatible APIs, in order to avoid breaking your app.
19+
일부 라이브러리는 React에서 지원하지 않는 패턴을 사용합니다. 린터가 [알려진 목록](https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts)에서 이러한 API의 사용을 감지하면 이 규칙에 따라 플래그를 지정합니다. 이는 React 컴파일러가 앱을 손상시키지 않기 위해 이러한 호환되지 않는 API를 사용하는 컴포넌트를 자동으로 건너뛸 수 있음을 의미합니다.
2020

2121
```js
22-
// Example of how memoization breaks with these libraries
22+
// 이러한 라이브러리로 메모이제이션이 깨지는 예시
2323
function Form() {
2424
const { watch } = useForm();
2525

26-
//This value will never update, even when 'name' field changes
26+
//'name' 필드가 변경되어도 이 값은 절대 업데이트되지 않습니다
2727
const name = useMemo(() => watch('name'), [watch]);
2828

29-
return <div>Name: {name}</div>; // UI appears "frozen"
29+
return <div>Name: {name}</div>; // UI가 "얼어붙은" 것처럼 보입니다
3030
}
3131
```
3232

33-
React Compiler automatically memoizes values following the Rules of React. If something breaks with manual `useMemo`, it will also break the compiler's automatic optimization. This rule helps identify these problematic patterns.
33+
React 컴파일러는 React 규칙을 따라 값을 자동으로 메모이제이션합니다. 수동 `useMemo`로 문제가 발생하면 컴파일러의 자동 최적화도 깨집니다. 이 규칙은 이러한 문제가 있는 패턴을 식별하는 데 도움이 됩니다.
3434

3535
<DeepDive>
3636

37-
#### Designing APIs that follow the Rules of React {/*designing-apis-that-follow-the-rules-of-react*/}
37+
#### React 규칙을 따르는 API 설계하기 {/*designing-apis-that-follow-the-rules-of-react*/}
3838

39-
One question to think about when designing a library API or hook is whether calling the API can be safely memoized with `useMemo`. If it can't, then both manual and React Compiler memoizations will break your user's code.
39+
라이브러리 API나 Hook을 설계할 때 고려해야 할 질문 중 하나는 API 호출을 `useMemo`로 안전하게 메모이제이션할 수 있는지 여부입니다. 그렇지 않다면 수동 메모이제이션과 React 컴파일러 메모이제이션 모두 사용자의 코드를 손상시킬 것입니다.
4040

41-
For example, one such incompatible pattern is "interior mutability". Interior mutability is when an object or function keeps its own hidden state that changes over time, even though the reference to it stays the same. Think of it like a box that looks the same on the outside but secretly rearranges its contents. React can't tell anything changed because it only checks if you gave it a different box, not what's inside. This breaks memoization, since React relies on the outer object (or function) changing if part of its value has changed.
41+
예를 들어, 이러한 호환되지 않는 패턴 중 하나는 "내부 가변성"입니다. 내부 가변성은 객체나 함수가 참조는 동일하게 유지되지만 시간이 지남에 따라 변경되는 자체 숨겨진 상태를 유지하는 것을 말합니다. 외부에서는 동일해 보이지만 내용물을 은밀하게 재배치하는 상자라고 생각하면 됩니다. React는 다른 상자를 받았는지만 확인하고 안에 무엇이 들어 있는지는 확인하지 않기 때문에 변경 사항을 알 수 없습니다. 이는 메모이제이션을 깨뜨리는데, React는 값의 일부가 변경된 경우 외부 객체(또는 함수)가 변경되는 것에 의존하기 때문입니다.
4242

43-
As a rule of thumb, when designing React APIs, think about whether `useMemo` would break it:
43+
React API를 설계할 때 경험 법칙으로, `useMemo`가 이를 깨뜨릴지 생각해보세요.
4444

4545
```js
4646
function Component() {
4747
const { someFunction } = useLibrary();
48-
// it should always be safe to memoize functions like this
48+
// 이와 같은 함수를 메모이제이션하는 것은 항상 안전해야 합니다
4949
const result = useMemo(() => someFunction(), [someFunction]);
5050
}
5151
```
5252

53-
Instead, design APIs that return immutable state and use explicit update functions:
53+
대신, 불변 상태를 반환하고 명시적인 업데이트 함수를 사용하는 API를 설계하세요.
5454

5555
```js
56-
//Good: Return immutable state that changes reference when updated
56+
//좋은 예시: 업데이트될 때 참조가 변경되는 불변 상태를 반환
5757
function Component() {
5858
const { field, updateField } = useLibrary();
59-
// this is always safe to memo
59+
// 이것은 항상 메모이제이션하기에 안전합니다
6060
const greeting = useMemo(() => `Hello, ${field.name}!`, [field.name]);
6161

6262
return (
@@ -73,15 +73,15 @@ function Component() {
7373

7474
</DeepDive>
7575

76-
### Invalid {/*invalid*/}
76+
### 잘못된 예 {/*invalid*/}
7777

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

8080
```js
8181
// ❌ react-hook-form `watch`
8282
function Component() {
8383
const {watch} = useForm();
84-
const value = watch('field'); // Interior mutability
84+
const value = watch('field'); // 내부 가변성
8585
return <div>{value}</div>;
8686
}
8787

@@ -92,7 +92,7 @@ function Component({data}) {
9292
columns,
9393
getCoreRowModel: getCoreRowModel(),
9494
});
95-
// table instance uses interior mutability
95+
// table 인스턴스가 내부 가변성을 사용합니다
9696
return <Table table={table} />;
9797
}
9898
```
@@ -101,24 +101,24 @@ function Component({data}) {
101101

102102
#### MobX {/*mobx*/}
103103

104-
MobX patterns like `observer` also break memoization assumptions, but the linter does not yet detect them. If you rely on MobX and find that your app doesn't work with React Compiler, you may need to use the `"use no memo" directive`.
104+
`observer`와 같은 MobX 패턴도 메모이제이션 가정을 깨뜨리지만, 린터는 아직 이를 감지하지 못합니다. MobX에 의존하고 있고 React 컴파일러에서 앱이 작동하지 않는다면 `"use no memo" 지시어`를 사용해야 할 수 있습니다.
105105

106106
```js
107107
// ❌ MobX `observer`
108108
const Component = observer(() => {
109109
const [timer] = useState(() => new Timer());
110-
return <span>Seconds passed: {timer.secondsPassed}</span>;
110+
return <span>경과된 시간: {timer.secondsPassed}</span>;
111111
});
112112
```
113113

114114
</Pitfall>
115115

116-
### Valid {/*valid*/}
116+
### 올바른 예 {/*valid*/}
117117

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

120120
```js
121-
//For react-hook-form, use `useWatch`:
121+
// ✅ react-hook-form의 경우 `useWatch`를 사용하세요
122122
function Component() {
123123
const {register, control} = useForm();
124124
const watchedValue = useWatch({
@@ -129,10 +129,10 @@ function Component() {
129129
return (
130130
<>
131131
<input {...register('field')} />
132-
<div>Current value: {watchedValue}</div>
132+
<div>현재 값: {watchedValue}</div>
133133
</>
134134
);
135135
}
136136
```
137137

138-
Some other libraries do not yet have alternative APIs that are compatible with React's memoization model. If the linter doesn't automatically skip over your components or hooks that call these APIs, please [file an issue](https://github.com/facebook/react/issues) so we can add it to the linter.
138+
일부 다른 라이브러리는 아직 React의 메모이제이션 모델과 호환되는 대체 API가 없습니다. 린터가 이러한 API를 호출하는 컴포넌트나 Hook을 자동으로 건너뛰지 않는다면 [이슈를 제출](https://github.com/facebook/react/issues)하여 린터에 추가할 수 있도록 해주세요.

0 commit comments

Comments
 (0)