Skip to content

Commit c002027

Browse files
committed
docs: translate flushSync troubleshooting section
1 parent e8701c4 commit c002027

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/content/reference/react-dom/flushSync.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,34 +133,34 @@ export default function PrintApp() {
133133

134134
---
135135

136-
## Troubleshooting {/*troubleshooting*/}
136+
## 문제 해결 {/*troubleshooting*/}
137137

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*/}
139139

140140

141-
React cannot `flushSync` in the middle of a render. If you do, it will noop and warn:
141+
React는 렌더링 도중에 `flushSync`를 실행할 수 없습니다. 렌더링 도중에 호출하면 아무 작업도 하지 않고 경고를 표시합니다.
142142

143143
<ConsoleBlock level="error">
144144

145145
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.
146146

147147
</ConsoleBlock>
148148

149-
This includes calling `flushSync` inside:
149+
다음 위치에서 `flushSync`를 호출하는 경우도 여기에 해당합니다.
150150

151-
- rendering a component.
152-
- `useLayoutEffect` or `useEffect` hooks.
153-
- Class component lifecycle methods.
151+
- 컴포넌트를 렌더링하는 도중
152+
- `useLayoutEffect` 또는 `useEffect` Hook
153+
- 클래스 컴포넌트의 생명주기 메서드
154154

155-
For example, calling `flushSync` in an Effect will noop and warn:
155+
예를 들어 Effect 안에서 `flushSync`를 호출하면 아무 작업도 하지 않고 경고를 표시합니다.
156156

157157
```js
158158
import { useEffect } from 'react';
159159
import { flushSync } from 'react-dom';
160160

161161
function MyComponent() {
162162
useEffect(() => {
163-
// 🚩 Wrong: calling flushSync inside an effect
163+
// 🚩 잘못된 방법: Effect 안에서 flushSync 호출
164164
flushSync(() => {
165165
setSomething(newValue);
166166
});
@@ -170,23 +170,23 @@ function MyComponent() {
170170
}
171171
```
172172

173-
To fix this, you usually want to move the `flushSync` call to an event:
173+
이 문제를 해결하려면 보통 `flushSync` 호출을 이벤트로 옮기면 됩니다.
174174

175175
```js
176176
function handleClick() {
177-
// ✅ Correct: flushSync in event handlers is safe
177+
// ✅ 올바른 방법: 이벤트 핸들러에서는 flushSync를 안전하게 호출할 수 있습니다
178178
flushSync(() => {
179179
setSomething(newValue);
180180
});
181181
}
182182
```
183183

184184

185-
If it's difficult to move to an event, you can defer `flushSync` in a microtask:
185+
이벤트로 옮기기 어렵다면 `flushSync`를 마이크로태스크로 미룰 수 있습니다.
186186

187187
```js {3,7}
188188
useEffect(() => {
189-
// ✅ Correct: defer flushSync to a microtask
189+
// ✅ 올바른 방법: flushSync를 마이크로태스크로 미루기
190190
queueMicrotask(() => {
191191
flushSync(() => {
192192
setSomething(newValue);
@@ -195,10 +195,10 @@ useEffect(() => {
195195
}, []);
196196
```
197197

198-
This will allow the current render to finish and schedule another synchronous render to flush the updates.
198+
이렇게 하면 현재 렌더링을 마친 뒤, 업데이트를 처리하기 위한 동기 렌더링을 한 번 더 예약합니다.
199199

200200
<Pitfall>
201201

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`를 호출하는 방법은 탈출구로만 사용하고, 그 전에 다른 모든 방법을 먼저 시도하세요.
203203

204204
</Pitfall>

0 commit comments

Comments
 (0)