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

When Bailout Checks Cost More Than Rendering

Identify scenarios where the comparison overhead exceeds the cost of just re-rendering a simple component.

When Bailout Checks Cost More Than Rendering

You'll learn when React.memo's overhead actually slows down your app instead of speeding it up.

The Overhead Paradox

React.memo isn't magic — it's a trade. React must execute the comparison function (either the default shallow check or your custom one) every time the parent renders. For simple components that render quickly, this comparison can actually take longer than just re-rendering the component.

Think of it like checking your grocery receipt for errors. If you only bought milk ($3), verifying the receipt takes more time than just glancing at the total. But if you bought 50 items, the verification effort is worth it.

When the Check Costs More

Consider a component that renders a single <div> with a string:

const SimpleLabel = React.memo(({ text }) => {
  return <div>{text}</div>;
});

React now must:

  1. Compare the old text prop with the new one
  2. Execute the memo bailout logic
  3. Only then decide whether to render

For such a trivial component, steps 1-2 can cost more CPU time than just rendering the <div>. You've added overhead without benefit.

The Rule of Thumb

Avoid React.memo for components that:

  • Render just a few simple DOM elements
  • Have no child components
  • Have no expensive calculations in their body
  • Re-render in microseconds

Key Takeaway: React.memo's prop comparison has a cost. For components that render faster than the comparison check itself, memo makes performance worse, not better. Profile before wrapping simple components.