The Cost of Complexity: Why I'm Moving Away from Global State
Back to Hub
Web Development Intermediate

The Cost of Complexity: Why I'm Moving Away from Global State

December 9, 2024
5 min read
P
Portfolio Owner

In this article

  • Don't optimize for hypothetical complexity.
  • Colocate state with the UI that uses it.
  • Global stores should be reserved for truly global data (auth, theme).

In the early days of a React project, it is tempting to dump everything into a global store. It feels organized. But three years later, you're debugging a toggle button that somehow triggers a user profile refresh. This post explores the 'state colocation' pattern, where we keep data as close to the component as possible. I discuss a recent refactor where moving 60% of our global state to local context reduced re-renders by half and made the onboarding process for new juniors significantly easier.

Share:
#React#State Management#Architecture#Refactoring
WhatsApp MeWhatsApp