State Management at Scale: It's Not About Size

4 min read

What "Scale" Actually Means in State Management

When we talk about state management at scale, the instinct is to think about metrics thousands of users, hundreds of components, millions of lines of code. That framing is wrong.

Scale is about maintainability and iteration speed as your app evolves.

The three real questions you need to answer about your codebase:

  1. Can you add features without breaking existing ones?
  2. Can teammates contribute confidently?
  3. Can you debug issues quickly?

If the answer to any of these is "not really," you have a scale problem regardless of app size.


The Three Dimensions of Scalable State 🎯

1. Feature Scalability

You want to extend your codebase to add new functionality, not gut it every time a new requirement comes in. The goal is additive changes over destructive refactors.

2. Team Scalability

In any non-trivial project, you're not coding alone. Consistent patterns across a codebase mean:

  1. Less confusion for engineers new to the project
  2. Less confusion for engineers who've been on it for years
  3. Fewer merge conflicts caused by diverging approaches

3. Complexity Scalability

This is the focus of this course. State that you can actually debug and understand even as features are added, changed, and fixed over time.


Who This Course Is For

This course targets React developers (and frontend developers broadly — Vue, Angular patterns apply) who are beyond the basics. Specifically:

  1. You're comfortable with core hooks: useState, useEffect, useRef
  2. You've used useContext, useReducer, useMemo
  3. You've worked on production React apps, large or small
  4. You may have legacy class component codebases to maintain

More importantly, you've likely hit these real-world problems:

  1. Tried third-party state management libraries and found them complex
  2. Tried building your own state solutions and watched them fall apart
  3. Dealt with an ever-growing list of features and bugs
  4. Hit the infinite loop in useEffect (everyone has)

The useEffect Chain Problem 💡

One of the most painful failure modes in large React apps: cascading useEffect hooks.

The pattern looks like this:

  1. Effect A triggers a state update
  2. That update triggers Effect B
  3. Effect B triggers Effect C
  4. A bug appears somewhere in the chain
  5. You have no idea which effect caused it

Debugging multiple chained useEffect hooks feels like tracing a Rube Goldberg machine instead of reading a state machine.

This course addresses this directly moving toward event-driven, declarative state management that makes data flow explicit and traceable.


Course Overview

What You'll Learn

The concepts are framework-agnostic by design. The focus is on:

  1. Core principles of state management architecture
  2. Common React anti-patterns and how to fix them
  3. Opportunities to make codebases clearer and more maintainable
  4. Event-driven state management patterns (drawn from state machines and statecharts)

The skills taught here are intentionally evergreen they hold true as React evolves, libraries change, and you move between frameworks.

What This Course Is NOT

  1. A deep dive into specialized React hooks or Next.js internals
  2. A course pushing you to adopt specific third-party libraries
  3. A "you must use this tool" prescription

Third-party state management libraries are optional. Many applications don't need them. Understanding why you would use one matters more than knowing how to install it.


The Core Goal: Understandability-First Architecture 🎯

David built XState — a library for state machines and statecharts while trying to make sense of complex async flows in legacy jQuery/PHP apps. The lesson wasn't "use state machines everywhere." It was: event-driven thinking produces understandable code.

That principle is what this course is built around. Applied to your React apps, it means:

  1. Your team can read and reason about the logic — not just the original author
  2. Edge cases and impossible states become visible — you can anticipate what can happen in your app, not just what should
  3. Legacy code becomes refactorable — clear state logic makes it safe to add features and fix bugs in old codebases

A Note on AI-Assisted Development

When your app logic is well-organized and your intent is explicit in code, LLMs understand it better too. Clear state management isn't just good for humans it improves the quality of AI-generated suggestions in tools like Cursor.


Workshop Structure

The repo is at github.com/davidkpiano/frontend-masters-state-workshop. Each lesson follows this structure:

FilePurpose
page.tsxMain working file for the exercise
README.mdLesson content + exercise description
scratchpadFree-form space for experimentation
solution/One example solution (not the only valid one)

Exercises are prefixed with exercise-. The first one covers anti-patterns.

Solutions in this workshop are a solution, not the solution. State management requirements vary there's no one-size-fits-all answer.