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
{{ message }}
Repository navigation
Commit c002027
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/flushSync.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,34 +133,34 @@ export default function PrintApp() {
133
133
134
134
---
135
135
136
-
## Troubleshooting {/*troubleshooting*/}
136
+
## 문제 해결 {/*troubleshooting*/}
137
137
138
-
### I'm getting an error: "flushSync was called from inside a lifecycle method" {/*im-getting-an-error-flushsync-was-called-from-inside-a-lifecycle-method*/}
138
+
### 오류가 발생합니다: "flushSync was called from inside a lifecycle method" {/*im-getting-an-error-flushsync-was-called-from-inside-a-lifecycle-method*/}
139
139
140
140
141
-
React cannot `flushSync` in the middle of a render. If you do, it will noop and warn:
141
+
React는 렌더링 도중에 `flushSync`를 실행할 수 없습니다. 렌더링 도중에 호출하면 아무 작업도 하지 않고 경고를 표시합니다.
142
142
143
143
<ConsoleBlocklevel="error">
144
144
145
145
Warning: flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.
146
146
147
147
</ConsoleBlock>
148
148
149
-
This includes calling `flushSync` inside:
149
+
다음 위치에서 `flushSync`를 호출하는 경우도 여기에 해당합니다.
150
150
151
-
-rendering a component.
152
-
-`useLayoutEffect`or`useEffect`hooks.
153
-
-Class component lifecycle methods.
151
+
-컴포넌트를 렌더링하는 도중
152
+
-`useLayoutEffect`또는`useEffect`Hook
153
+
-클래스 컴포넌트의 생명주기 메서드
154
154
155
-
For example, calling `flushSync` in an Effect will noop and warn:
155
+
예를 들어 Effect 안에서 `flushSync`를 호출하면 아무 작업도 하지 않고 경고를 표시합니다.
156
156
157
157
```js
158
158
import { useEffect } from'react';
159
159
import { flushSync } from'react-dom';
160
160
161
161
functionMyComponent() {
162
162
useEffect(() => {
163
-
// 🚩 Wrong: calling flushSync inside an effect
163
+
// 🚩 잘못된 방법: Effect 안에서 flushSync 호출
164
164
flushSync(() => {
165
165
setSomething(newValue);
166
166
});
@@ -170,23 +170,23 @@ function MyComponent() {
170
170
}
171
171
```
172
172
173
-
To fix this, you usually want to move the `flushSync`call to an event:
173
+
이 문제를 해결하려면 보통 `flushSync`호출을 이벤트로 옮기면 됩니다.
174
174
175
175
```js
176
176
functionhandleClick() {
177
-
// ✅ Correct: flushSync in event handlers is safe
177
+
// ✅ 올바른 방법: 이벤트 핸들러에서는 flushSync를 안전하게 호출할 수 있습니다
178
178
flushSync(() => {
179
179
setSomething(newValue);
180
180
});
181
181
}
182
182
```
183
183
184
184
185
-
If it's difficult to move to an event, you can defer `flushSync` in a microtask:
185
+
이벤트로 옮기기 어렵다면 `flushSync`를 마이크로태스크로 미룰 수 있습니다.
186
186
187
187
```js {3,7}
188
188
useEffect(() => {
189
-
// ✅ Correct: defer flushSync to a microtask
189
+
// ✅ 올바른 방법: flushSync를 마이크로태스크로 미루기
190
190
queueMicrotask(() => {
191
191
flushSync(() => {
192
192
setSomething(newValue);
@@ -195,10 +195,10 @@ useEffect(() => {
195
195
}, []);
196
196
```
197
197
198
-
This will allow the current render to finish and schedule another synchronous render to flush the updates.
198
+
이렇게 하면 현재 렌더링을 마친 뒤, 업데이트를 처리하기 위한 동기 렌더링을 한 번 더 예약합니다.
199
199
200
200
<Pitfall>
201
201
202
-
`flushSync` can significantly hurt performance, but this particular pattern is even worse for performance. Exhaust all other options before calling `flushSync` in a microtask as an escape hatch.
202
+
`flushSync`는 성능을 크게 저하할 수 있는데, 이 패턴은 성능에 더 나쁩니다. 마이크로태스크에서 `flushSync`를 호출하는 방법은 탈출구로만 사용하고, 그 전에 다른 모든 방법을 먼저 시도하세요.
0 commit comments