DEV Community

Discussion on: You don't need a library for state machines

Collapse
 
joaozitopolo profile image
Joao Polo

I just added the xstate lib on my react project to control things...
I done three comparisons:

  • with "useState", the more confuse approach because I can have intermediary steps (for example, I can set loading by true, but I already have old data on other fields)
  • with "useReducer", a clear method, but so verbosely
  • with "useMachine" (xstate lib), a clear and not so big implementation like useReducer.

But for me, it's not the best approach, yet... maybe the old immutable objects approach should be a better solution. I'll try it also.

Thanks for your article, it was awesome to read.