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/set-state-in-effect.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: set-state-in-effect
4
4
5
5
<Intro>
6
6
7
-
Effect에서 setState를 동기적으로 호출하는 것에 대해 검증합니다. 이는 성능을 저하시키는 재렌더링으로 이어질 수 있습니다.
7
+
Effect에서 `setState`를 동기적으로 호출하는 것에 대해 검증합니다. 이는 성능을 저하시키는 재렌더링으로 이어질 수 있습니다.
8
8
9
9
</Intro>
10
10
@@ -14,11 +14,11 @@ Effect 내부에서 즉시 state를 설정하면 React가 전체 렌더링 사
14
14
15
15
Effect에서 동기적으로 `setState`를 호출하면 브라우저가 페인트하기 전에 즉시 재렌더링이 트리거되어 성능 문제와 시각적 끊김이 발생합니다. React는 두 번 렌더링해야 합니다. 한 번은 state 업데이트를 적용하고, 또 한 번은 Effect가 실행된 후입니다. 단일 렌더링으로 동일한 결과를 얻을 수 있을 때 이러한 이중 렌더링은 낭비입니다.
16
16
17
-
많은 경우 Effect가 전혀 필요하지 않을 수도 있습니다. 자세한 내용은 [Effect가 필요하지 않을 수 있습니다](/learn/you-might-not-need-an-effect)를 참고하세요.
17
+
많은 경우 Effect가 전혀 필요하지 않을 수도 있습니다. 자세한 내용은 [Effect가 필요하지 않은 경우](/learn/you-might-not-need-an-effect)를 참고하세요.
18
18
19
19
## 일반적인 위반 사례 {/*common-violations*/}
20
20
21
-
이 규칙은 동기적으로 setState가 불필요하게 사용되는 여러 패턴을 감지합니다.
21
+
이 규칙은 동기적으로 `setState`가 불필요하게 사용되는 여러 패턴을 감지합니다.
22
22
23
23
- 로딩 상태를 동기적으로 설정
24
24
- Effect에서 props로부터 state 파생
@@ -53,7 +53,7 @@ function Component({rawData}) {
53
53
const [processed, setProcessed] =useState([]);
54
54
55
55
useEffect(() => {
56
-
setProcessed(rawData.map(transform)); // 렌더링 중에 파생해야 함
56
+
setProcessed(rawData.map(transform)); // 렌더링 중에 생성해야 함
57
57
}, [rawData]);
58
58
}
59
59
@@ -90,4 +90,4 @@ function Component({selectedId, items}) {
90
90
}
91
91
```
92
92
93
-
**기존 props나 state로부터 계산할 수 있는 경우 state에 넣지 마세요.** 대신 렌더링 중에 계산하세요. 이렇게 하면 코드가 더 빠르고 간단하며 오류가 덜 발생합니다. 자세한 내용은 [Effect가 필요하지 않을 수 있습니다](/learn/you-might-not-need-an-effect)를 참고하세요.
93
+
**기존 props나 state로부터 계산할 수 있는 경우 state에 넣지 마세요.** 대신 렌더링 중에 계산하세요. 이렇게 하면 코드가 더 빠르고 간단하며 오류가 덜 발생합니다. 자세한 내용은 [Effect가 필요하지 않은 경우](/learn/you-might-not-need-an-effect)를 참고하세요.
Copy file name to clipboardExpand all lines: src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,4 +107,4 @@ function Counter({max}) {
107
107
108
108
이제 setter는 클릭에 대한 응답으로만 실행되고, React는 정상적으로 렌더링을 완료하며, `count`는 절대 `max`를 넘지 않습니다.
109
109
110
-
드문 경우지만 이전 렌더링의 정보를 기반으로 state를 조정해야 할 수 있습니다. 그런 경우 조건부로 state를 설정하는 [이 패턴](https://react.dev/reference/react/useState#storing-information-from-previous-renders)을 따르세요.
110
+
드문 경우지만 이전 렌더링의 정보를 기반으로 state를 조정해야 할 수 있습니다. 그런 경우 조건부로 state를 설정하는 [이 패턴](/reference/react/useState#storing-information-from-previous-renders)을 따르세요.
0 commit comments