Course contentsShow
← React
Lesson 831 of 2,39622. Context PerformanceFree lesson

Multiple Consumers, Multiple Re-renders

Observing how dozens of components can re-render from a single context value update, creating performance bottlenecks.

Multiple Consumers, Multiple Re-renders

You'll learn how a single context value change can cascade into dozens of component re-renders, creating real performance problems.

The Cascade Effect

When context value changes, every component that calls useContext for that context re-renders — not just one, not just nearby consumers, but all of them across your entire component tree.

Imagine a company-wide announcement system. When the CEO sends one message, everyone who's subscribed to announcements gets it simultaneously. Now imagine you have 50 employees subscribed. That's 50 people who stop what they're doing to read the message — even if only 2 of them actually needed to know.

That's exactly what happens with context: one value update triggers re-renders in every consumer, regardless of whether each component actually cares about the specific data that changed.

Why This Creates Bottlenecks

// One context update...
<AuthContext.Provider value={{ user, settings, preferences, notifications }}>
  <Header />        {/* Re-renders */}
  <Sidebar />       {/* Re-renders */}
  <Dashboard />     {/* Re-renders */}
  <Profile />       {/* Re-renders */}
  <Settings />      {/* Re-renders */}
  <Notifications /> {/* Re-renders */}
  {/* 20+ more consumers... all re-render */}
</AuthContext.Provider>

If notifications changes, all 26+ components re-render, even though 25 of them only care about user. This is the multiple consumers, multiple re-renders problem: the cost multiplies with the number of consumers.

With a handful of consumers, it's negligible. With dozens or hundreds, you'll see lag, especially if those components have expensive render logic.

Key Takeaway: Context updates trigger re-renders in all consumers simultaneously, making the performance cost scale linearly with the number of components using that context — a common source of performance bottlenecks in large applications.