Yeda AI Tips · #182

Español

Overusing React.memo and useMemo Is a Red Flag

useMemo everywhere is not making your app faster.

Somewhere a rule of thumb turned into a habit: wrap every component in React.memo, every derived value in useMemo, every callback in useCallback, just in case. It looks like performance work. Mostly it's noise. Memoization isn't free, and applying it blindly can make an app slower and definitely makes it harder to read. Overusing memo is as much a red flag as never using it.

Memoization has a cost

Every memo does bookkeeping so it can skip work later:

So the mental model "memo = faster" is wrong. Memo trades comparison work now to avoid recompute work later. It only pays off when the avoided work is genuinely expensive and actually avoided.

Measure first, then memoize

The right order is measure, then optimize:

  1. Profile. Use the React Profiler (or the DevTools flamegraph) to find the components that actually re-render often and cost real time. Record an interaction that feels slow.
  2. Find the real bottleneck. It's usually a small number of components or one expensive computation, not the whole tree.
  3. Memoize only that. Apply useMemo to the genuinely expensive calculation, React.memo to the component that re-renders needlessly with stable props. Leave the rest alone.
// Red flag: memoizing a trivial value "just in case"
const label = useMemo(() => `${first} ${last}`, [first, last]); // pointless

// Justified: the profiler showed this sort dominates render time
const sorted = useMemo(
  () => bigList.slice().sort(expensiveComparator), // real cost, avoided
  [bigList]
);

What good looks like

HabitSignal
Memoize everything by defaultRed flag: added complexity, comparison cost, no measured win
Memoize what a profile proved slowGreen flag: targeted, defensible, still readable
Reach for memo before profilingRed flag: optimizing blind

The payoff of measuring first is less noise, real wins, and code that stays readable. A memo you can point to a flamegraph and justify is worth it. One you added out of superstition is just tech debt that looks like diligence.

Power moves

Resources

Shipping AI or cloud systems? Yeda AI audits and hardens production LLM and cloud pipelines. Talk to us · Read the blog