Wiki: You (probably) Don’t Need Global State Management
For agents: Markdown version · Wiki index · Explore
- Speaker: Shai Yallin
- Event: Reversim Summit 2022
- Video: https://www.youtube.com/watch?v=48nIJc1ek8o
- Transcript: /transcripts/2022/07-48nIJc1ek8o.md
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: Frontend, Software Engineering, JavaScript, Technical Debt
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
The speaker argues that web applications often rely unnecessarily on global state management libraries, which can increase code complexity and make future changes difficult. Instead, developers should prioritize local state, component encapsulation, and unidirectional data flow using built-in framework features. The audience learns practical strategies for replacing global stores with custom hooks, React context, and server-cache libraries only when genuinely needed.
Key points
- 3:30 Optimizing for changeability is the most crucial goal in software engineering to prevent early technical debt from slowing down future development.
- 4:34 Global state makes code hard to understand and modify because it creates tight coupling and obscures which components depend on specific parts of the state.
- 6:39 Modern UI frameworks with component-local state and unidirectional data flow allow developers to isolate data and avoid global pollution.
- 9:50 Using global state libraries like Redux often leads to an anti-pattern where private component state leaks into the global store, increasing complexity.
- 14:09 Alternative global state solutions like MobX introduce heavy verbosity and paradigm mismatches that complicate debugging and testing.
- 15:18 Developers can effectively manage component state and side effects using built-in framework hooks without relying on external state libraries.
- 27:03 If an existing application is stuck with global state management, developers should first secure the codebase with tests before refactoring opportunistically.
Takeaways
- Start building applications without global state libraries, relying on local state and custom hooks first.
- Introduce caching or global context strictly when a proven, measurable need arises rather than by default.
- Establish a robust safety net of tests before attempting to refactor legacy code out of a global state architecture.
Questions this talk answers
- Why is global state management considered harmful to the changeability of a frontend codebase?
- How can I manage server data caching and state sharing in React without using a heavy global store?
- What is the recommended strategy for migrating a legacy application away from Redux or MobX?
Technologies
JavaScript, React, Redux, MobX
Tags
clean code, frontend architecture, hooks, react, refactoring, state management