DEV Community

Discussion on: My thoughts on endless battle of React state management libraries (setState/useState vs Redux vs Mobx)

Collapse
 
psiho profile image
Mirko Vukušić

I dont do huge apps, but Mobx worked really well and I haven't run into any of the mentioned issues. I split state into multiple Mobx stores, organized hierarchically. So only RootStore usually gets pushed through provider and other stores are accessible through it. Also parent store is referenced by child store so you can go up the hierarchy too. Basically, its what Mobx docs suggest: mobx.js.org/best/store.html

I must say I also haven't had any unexpected behavior. Quite oposite. "Scratching my head" with React usually was about why some component was rerendering more than once, or even twice. I'm really careful about optimization there. Hate to see rendering time wasted. I find that goes away with Mobx. React state, Memo, and other ways to fight it are in my opinion much more complex thatn Mobx. In Mobx, all you have to remember basically is "dereference values as late as possible" (one point from Mobx docs: mobx.js.org/best/pitfalls.html)

Collapse
 
mpodlasin profile image
mpodlasin

Hey Mirko. Thanks for commenting.

Maybe that wasn't entirely clear in the article, but I DO consider Mobx superior to Redux in most of use cases.

I didn't have "scratch my head" moments too often when developing an app, but I still felt that I am not fully in control of the framework.

This article wasn't meant to bash Mobx (or even Redux). If it works well for you, by all means continue to use it.

Collapse
 
psiho profile image
Mirko Vukušić

No, no, I haven't foind your article to bash Mobx. Just focussed on Mobx part of it, trying to find myself there, but didnt :). And wanted to share.

Mobx is a "magic black box" often, but I got so used to it that it doesn't serve me any surprises.

Thread Thread
 
mpodlasin profile image
mpodlasin

Fair enough!

Glad it works for you. Thanks for the comment. :)