Course contentsShow
← React
Lesson 2253 of 2,39649. Performance: Identifying ProblemsFree lesson

Splitting Context by Update Frequency

Strategy of separating frequently-changing values into their own context to minimize re-render blast radius.

Splitting Context by Update Frequency

You'll learn how to minimize unnecessary re-renders by separating frequently-changing context values into their own dedicated context.


When a context provider's value changes, every component consuming that context re-renders—even if they only care about part of the data. If your context holds both frequently-changing values (like user input) and rarely-changing values (like theme settings), you're forcing unnecessary updates on components that only need the stable data.

The solution: split your context by update frequency. Create separate contexts for values that change at different rates. Components can then subscribe only to the data they actually use, dramatically reducing the re-render blast radius.

The Problem

Imagine a single AppContext holding both user (changes once at login) and searchQuery (changes on every keystroke). Every consumer re-renders with each keystroke, even if they only display the user's name.

The Strategy

  1. Identify update patterns: Which values change frequently? Which are stable?
  2. Create separate contexts: One for fast-changing data, another for slow-changing data
  3. Let components opt-in: Each component imports only the context it needs
  4. Measure the impact: Use the Profiler to verify fewer components re-render

Example Structure

Instead of one AppContext, you might have:

  • UserContext (changes once per session)
  • SearchContext (changes per keystroke)
  • ThemeContext (changes rarely)

A user profile component imports only UserContext. A search results component imports only SearchContext. Each re-renders only when its data changes.

Key Takeaway: Splitting context by how often values change lets components subscribe only to relevant updates, preventing fast-changing data from triggering unnecessary re-renders across your entire tree.