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 21ce438
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/content/reference/react/memo.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -361,16 +361,16 @@ function arePropsEqual(oldProps, newProps) {
361
361
362
362
---
363
363
364
-
### Do I still need React.memo if I use React Compiler? {/*react-compiler-memo*/}
364
+
### React 컴파일러를 사용한다면 React.memo가 여전히 필요한가요? {/*react-compiler-memo*/}
365
365
366
-
When you enable [React Compiler](/learn/react-compiler), you typically don't need `React.memo` anymore. The compiler automatically optimizes component re-rendering for you.
366
+
[React 컴파일러](/learn/react-compiler)를 활성화하면 일반적으로 `React.memo`가 더 이상 필요하지 않습니다. 컴파일러가 컴포넌트 리렌더링을 자동으로 최적화해 주기 때문입니다.
367
367
368
-
Here's how it works:
368
+
작동 방식은 다음과 같습니다.
369
369
370
-
**Without React Compiler**, you need `React.memo` to prevent unnecessary re-renders:
370
+
**React 컴파일러를 활성화하지 않으면** 불필요한 리렌더링을 막기 위해 `React.memo`가 필요합니다.
371
371
372
372
```js
373
-
//Parent re-renders every second
373
+
//부모가 매초 리렌더링됩니다
374
374
functionParent() {
375
375
const [seconds, setSeconds] =useState(0);
376
376
@@ -389,30 +389,30 @@ function Parent() {
389
389
);
390
390
}
391
391
392
-
//Without memo, this re-renders every second even though props don't change
392
+
//memo가 없으면 Props가 변경되지 않아도 매초 리렌더링됩니다
393
393
constExpensiveChild=memo(functionExpensiveChild({ name }) {
394
394
console.log('ExpensiveChild rendered');
395
395
return<div>Hello, {name}!</div>;
396
396
});
397
397
```
398
398
399
-
**With React Compiler enabled**, the same optimization happens automatically:
Here's the key part of what the React Compiler generates:
409
+
React 컴파일러가 생성하는 코드의 핵심 부분은 다음과 같습니다.
410
410
411
411
```js {6-12}
412
412
functionParent() {
413
413
const$=_c(7);
414
414
const [seconds, setSeconds] =useState(0);
415
-
// ... other code ...
415
+
// ... 그 외 코드 ...
416
416
417
417
let t3;
418
418
if ($[4] ===Symbol.for("react.memo_cache_sentinel")) {
@@ -421,22 +421,22 @@ function Parent() {
421
421
} else {
422
422
t3 = $[4];
423
423
}
424
-
// ... return statement ...
424
+
// ... return 문 ...
425
425
}
426
426
```
427
427
428
-
Notice the highlighted lines: The compiler wraps `<ExpensiveChild name="John" />` in a cache check. Since the `name`prop is always `"John"`, this JSX is created once and reused on every parent re-render. This is exactly what `React.memo` does - it prevents the child from re-rendering when its props haven't changed.
428
+
강조된 줄을 살펴보세요. 컴파일러는 `<ExpensiveChild name="John" />`를 캐시 검사로 감쌉니다. `name`Prop이 항상 `"John"`이므로, 이 JSX는 한 번만 생성되고 부모가 리렌더링될 때마다 재사용됩니다. 이는 정확히 `React.memo`가 하는 일과 같습니다. 즉, 자식의 Props가 변경되지 않았을 때 자식이 리렌더링되지 않도록 막아 줍니다.
429
429
430
-
The React Compiler automatically:
431
-
1.Tracks that the `name`prop passed to `ExpensiveChild` hasn't changed
432
-
2.Reuses the previously created JSX for `<ExpensiveChild name="John" />`
This means **you can safely remove `React.memo` from your components when using React Compiler**. The compiler provides the same optimization automatically, making your code cleaner and easier to maintain.
435
+
즉, **React 컴파일러를 사용할 때는 컴포넌트에서 `React.memo`를 안전하게 제거할 수 있습니다.** 컴파일러가 동일한 최적화를 자동으로 제공하므로 코드가 더 깔끔해지고 유지보수하기 쉬워집니다.
436
436
437
437
<Note>
438
438
439
-
The compiler's optimization is actually more comprehensive than `React.memo`. It also memoizes intermediate values and expensive computations within your components, similar to combining `React.memo` with `useMemo` throughout your component tree.
439
+
컴파일러의 최적화는 사실 `React.memo`보다 더 포괄적입니다. 컴포넌트 내부의 중간값과 비용이 많이 드는 계산까지 메모이제이션하는데, 이는 컴포넌트 트리 전반에 걸쳐 `React.memo`와 `useMemo`를 함께 사용하는 것과 비슷합니다.
0 commit comments