Ditching setState for MobX
Nader Dabit
3.6K19

Mobx is certainly an alternative. But as it has been argued by Ryan Florence in that "3 Reasons why I stopped using react setState" by Weststrate.

  • MobX is synchronous while setState is asynchronous

You can user setState's callback to make sure you don't have any async bugs.

  • setState causes unnecessary renders

By understanding well how the component lifecycle works I doubt this is a problem. At least I can't remember out of my head any situations where I couldn't avoid a unnecessary re-render. I'd love to see an example where this happens and maybe we can check it out.

  • setState is not sufficient to capture all component state

"timers, network requests, events etc." these can be instance properties.

TLDR;
Mobx is a great library it works nicely I agree and also has some cool things to offer like computed values, autorun, reaction and when. For those really into reactive programming I guess it's a good call. However, besides the extra things Mobx has to offer, the main arguments over setState aren't very accurate. As a Tech Lead I'd appreciate more if the devs on my team highly understand how React works rather than learn it poorly and just use another library to compensate which is also another overhead.