07-debuggable-state/01-why-reducers-matter.md
Why reducers matter
Why reducers matter
Reducers are one of the most important tools for keeping Vroq apps understandable and debuggable.
A reducer makes state transitions explicit. Instead of letting state updates happen in many scattered places, reducers centralize how a state slice changes in response to actions.
Why this helps
Reducers make it easier to:
- inspect state transitions
- understand feature ownership
- replay actions during debugging
- keep UI code simpler
- avoid hidden mutation and special-case updates
This is especially helpful for LLMs, because explicit state transitions are easier to reason about than state updates scattered across UI files.
Reducers as architecture tools
Reducers are not only for state management. They also define boundaries.
A reducer helps answer:
- which feature owns this state?
- where should this bug be fixed?
- what actions are allowed to change this slice?
That clarity reduces hacky fixes.
What goes wrong without reducers
Without clear reducer ownership, apps tend to drift into:
- UI files mutating state indirectly
- duplicated update logic
- hidden assumptions spread across several files
- difficult debugging because transitions are not explicit
Final rule
Use reducers to make feature state ownership and transitions explicit, visible, and easy to debug.