Hello, I am new in ReactJS and I just heared that using state management will make our life easier. I am asking what is good MobX or Redux for me that is newbie in ReactJS, and why?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (7)
I personally favor Redux. Unidirectional data flow and a functional programming style is what I really like about it.
However, if you just started to use React I would opt for normal component state first (check out Lifting Up State). Then, when you felt the pain of - for example - prop drilling, I would take a look at Redux. Redux really only makes sense in bigger projects with a bunch of components.
Thank you for that. I really appreciate your comment
As other's have already say, neither if you're just starting out. Here's a great article on Medium about not using redux, medium.com/@blairanderson/you-prob....
When I first started learning React, I read all kinds of blog posts with "Tips for React beginners" insinuating that it's a must-use-library. Which almost had me quit on react altogether. So if I were you, I'd focus on learning React well, and then pick up Redux when you feel the need, when it comes.
Thank you for this. I really appreciate it, I decided to not use some state management first, I'll focus first on React.
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.
I realized now that it is much better not to use any state management in reactjs, specially when you are starting learning in reactjs. It is really helpful to study how to pass props to other components.
I would say neither if you are just starting out. I haven't figured out why devs default to using any library before figuring out if they really need it for the project. Check out the new Context API in the latest version of React, it will get you really far.
Disclaimer: I strongly dislike Redux.