diff --git a/src/content/reference/react-dom/flushSync.md b/src/content/reference/react-dom/flushSync.md index e4c77c42e..00c2a72c2 100644 --- a/src/content/reference/react-dom/flushSync.md +++ b/src/content/reference/react-dom/flushSync.md @@ -133,12 +133,12 @@ export default function PrintApp() { --- -## Troubleshooting {/*troubleshooting*/} +## 문제 해결 {/*troubleshooting*/} -### 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*/} +### 오류가 발생합니다: "flushSync was called from inside a lifecycle method" {/*im-getting-an-error-flushsync-was-called-from-inside-a-lifecycle-method*/} -React cannot `flushSync` in the middle of a render. If you do, it will noop and warn: +React는 렌더링 도중에 `flushSync`를 실행할 수 없습니다. 렌더링 도중에 호출하면 아무 작업도 하지 않고 경고를 표시합니다. @@ -146,13 +146,13 @@ Warning: flushSync was called from inside a lifecycle method. React cannot flush -This includes calling `flushSync` inside: +다음 위치에서 `flushSync`를 호출하는 경우도 여기에 해당합니다. -- rendering a component. -- `useLayoutEffect` or `useEffect` hooks. -- Class component lifecycle methods. +- 컴포넌트를 렌더링하는 도중 +- `useLayoutEffect` 또는 `useEffect` Hook +- 클래스 컴포넌트의 생명주기 메서드 -For example, calling `flushSync` in an Effect will noop and warn: +예를 들어 Effect 안에서 `flushSync`를 호출하면 아무 작업도 하지 않고 경고를 표시합니다. ```js import { useEffect } from 'react'; @@ -160,7 +160,7 @@ import { flushSync } from 'react-dom'; function MyComponent() { useEffect(() => { - // 🚩 Wrong: calling flushSync inside an effect + // 🚩 잘못된 방법: Effect 안에서 flushSync 호출 flushSync(() => { setSomething(newValue); }); @@ -170,11 +170,11 @@ function MyComponent() { } ``` -To fix this, you usually want to move the `flushSync` call to an event: +이 문제를 해결하려면 보통 `flushSync` 호출을 이벤트로 옮기면 됩니다. ```js function handleClick() { - // ✅ Correct: flushSync in event handlers is safe + // ✅ 올바른 방법: 이벤트 핸들러에서는 flushSync를 안전하게 호출할 수 있습니다 flushSync(() => { setSomething(newValue); }); @@ -182,11 +182,11 @@ function handleClick() { ``` -If it's difficult to move to an event, you can defer `flushSync` in a microtask: +이벤트로 옮기기 어렵다면 `flushSync`를 마이크로태스크로 미룰 수 있습니다. ```js {3,7} useEffect(() => { - // ✅ Correct: defer flushSync to a microtask + // ✅ 올바른 방법: flushSync를 마이크로태스크로 미루기 queueMicrotask(() => { flushSync(() => { setSomething(newValue); @@ -195,10 +195,10 @@ useEffect(() => { }, []); ``` -This will allow the current render to finish and schedule another synchronous render to flush the updates. +이렇게 하면 현재 렌더링을 마친 뒤, 업데이트를 처리하기 위한 동기 렌더링을 한 번 더 예약합니다. -`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. +`flushSync`는 성능을 크게 저하할 수 있는데, 이 패턴은 성능에 더 나쁩니다. 마이크로태스크에서 `flushSync`를 호출하는 방법은 탈출구로만 사용하고, 그 전에 다른 모든 방법을 먼저 시도하세요.