State Management · Senior · Question 50 of 75
When is a finite state machine (e.g. XState) a better model than a reducer with flags?
- ✓Correct answer: For complex flows with many states and guarded transitions (checkout, video player, wizards)
- 2For any boolean toggle
- 3Never - reducers can't express states
Explanation
Flags like isLoading/isError/isSuccess allow impossible combinations. A machine (or a reducer over a discriminated union) makes states explicit and transitions guarded; statecharts add nesting and parallel states.