Course contentsShow
← React
Lesson 931 of 2,39624. React.memoFree lesson

React.memo Helps When Props are Stable but Parent Re-renders

Identify scenarios where a component's props don't change, but it re-renders because its parent does.

React.memo Helps When Props are Stable but Parent Re-renders

What you'll learn: You'll identify the specific scenario where React.memo provides the most value—when a component receives stable props but re-renders unnecessarily due to its parent.

The Perfect Use Case for React.memo

This is the "sweet spot" where React.memo shines. Imagine a parent component that re-renders frequently (perhaps it has rapidly changing state), but passes down the same exact props to a child component. Without memo, that child re-renders every single time—even though nothing about it changed.

The scenario:

  • Parent component updates frequently (timer, scroll position, form input)
  • Child component receives props that don't change (or change rarely)
  • Child's render is somewhat expensive
  • Result: wasted work rendering the same output repeatedly

Real-World Example Pattern

Think of a dashboard with a live-updating chart and a static sidebar. Every time the chart data updates, the sidebar doesn't need to re-render—its props (navigation links, user info) haven't changed. But React's default behavior says "parent rendered, so children render too."

This is where wrapping the sidebar in React.memo makes perfect sense. The shallow prop comparison is cheap, the props genuinely are stable, and you avoid the unnecessary render work.

When This Scenario Occurs

  • Parent has local state that changes frequently
  • Child receives props from outside that state (constants, context values, memoized values)
  • Child is "downstream" from the changing state but not affected by it
  • Multiple children exist, but only some need the updated data

Key Takeaway: React.memo delivers real performance wins when your component receives stable props but would otherwise re-render due to parent updates—this is the classic optimization scenario it was designed for.