State Management · Senior · Question 50 of 75

When is a finite state machine (e.g. XState) a better model than a reducer with flags?

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.

Further reading

Problem with a question

State Management · Senior · question 50

Test yourself

Take the State Management · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz