Andrei Calazans
May 9, 2018 · 1 min read

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.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store