Chapter 5
Patterns
React.memo
Pure Function
const add = (a, b) => a + b;
Copied!
ComponentResult
⚠️ RegularAdd3
βœ… MemoizedAdd3
⚠️ NonMemoizedAddWithObjProp3

* Click each row to see the source code for the component** Check the logs printed in the console

"use client";

// λ©”λͺ¨μ΄μ œμ΄μ…˜λ˜μ§€ μ•Šμ€ μ»΄ν¬λ„ŒνŠΈ: λΆ€λͺ¨κ°€ λ¦¬λ Œλ”λ§λ˜λ©΄ 맀번 λ Œλ”λ§λ¨
// causes re-render on parent re-render
const RegularAdd = ({ n1, n2 }) => {
  return (
    <>
      <td>⚠️ RegularAdd</td>
      <td>{n1 + n2}</td>
    </>
  );
};
Copied!