The Single Large Context Antipattern
What you'll learn: How putting all your application state into one massive context creates a performance disaster.
The Problem with One Giant Context
Imagine you have a GlobalAppContext that holds everything: user info, theme settings, shopping cart, notifications, UI state, and more. It seems convenient—one context to rule them all!
Here's the performance trap: every time any piece of that context changes, every component that reads from it re-renders, even if they only care about one tiny slice of the data.
Your theme toggle button changes theme from "light" to "dark"? Every component using the context re-renders—including your shopping cart, your user profile, your notification list. None of them needed to update, but they all did anyway.
Why This Happens
Context doesn't have "selective subscriptions." When you call useContext(GlobalAppContext), React subscribes that component to the entire context value. Change any property in the context object? All consumers re-render.
// Antipattern: Everything in one context
const GlobalAppContext = createContext();
// ShoppingCart re-renders when theme changes
// ThemeToggle re-renders when cart changes
// Everything re-renders when anything changes
The Real Cost
You'll see this in the Profiler: cascading renders across unrelated components, all triggered by a single context update. Components that didn't need to update are wasting CPU cycles reconciling identical output.
Key Takeaway: Putting all state in one context creates unnecessary coupling—every consumer becomes sensitive to every state change, causing performance problems that are hard to fix without splitting contexts.