Skip to content
loading...

re: Redux or MobX for ReactJS? VIEW POST

FULL DISCUSSION
 

I agree with Chris. Start out by really understanding React state (if you don't already).

However, at some point, you'll have a more complex application you'll want to build and I think it's good to understand your options. I believe both MobX and Redux make your life easier on non-trivial apps.

I've been using Redux for about 2.5 years on my team (although it somehow worked out that I've only used for substantive things for 1.5 years - so I'm not as familiar with it as some of my colleagues). It's a great model if you can follow its clearly defined principles in a disciplined manner. It's also pretty easy to understanding and use. The downside is the amount of boilerplate, which impedes reuse of more complex components. There's certainly a learning curve. We've got some JS newbies on my team, and it's been a struggle for them to grasp Redux. From an engineering standpoint, I think that Redux is very simple, and even though there are pain points, there are huge benefits you get from being able to cleanly TDD and from the lower cognitive load.

The bottom line is that from the learner's standpoint, it's great because you'll be exposed to one of the best Flux implementations and you can get acclimated to that architecture. So definitely check it out. The protip I've got is that if your intention is to build a component eco-system like a pattern library, then Redux might trip you up some.

I've used MobX on a couple of side-project to see if it's easy to learn and whether it facilitates reuse. From limited experience, I believe that it's much better at facilitating composability in your complex components (organism-level if you know Atomic Design) - which is one of the strengths of React. So from that perspective, it seems to play better with React in some ways. I think that its greatest strength is its lack of substantial boilerplate - but that strength can also become a weakness since it achieves that with "magic" functions (basically decorators that are actually higher order components under the hood). Overall it was a promising experience, but there are lingering concerns around how MobX mutates your data, and I haven't investigated too deeply on how to test-drive advanced MobX code, whereas Redux code is pretty straightforward.

I know this won't be much help, but I think that there's merit in exploring both. Neither is the world-beating solution.

code of conduct - report abuse