Hello everyone!
In this repo, I am going to compare two libraries designated to React (i.e. Redux and Mobx) Both library is related and specified to storing data in React along with other state management techniques. I suggest you to refer to other repo of mine to know how to use redux in detail. so, If you search on the internet for these two libraries and do some real project as I did, you reach a list of cons and pros as below:
The structure of how the library is working is in the repository I just mentioned above is like this:
The description is simple: Suppose 'store' as a watermelon and 'slicers' as pieces of it containing 'reducers', and 'data', to be used in a 'component' as a plate. Or imagine 'store' as a 'database', 'tables' as 'slices', 'queries' as 'reducers' and 'data', to be used in html view... You can find other description of how things are working on the internet, like these:
or this in comparison to Flux:
But MobX is a little bit different: as it's being mentioned in its official guide, it is supposed to be simpler and more scalable. I'm telling you that I agree with them in first term but scalability is a bit tricky and shoule be tested on huge applications. Frankly I didn't test it on large and compliceted databases but MobX official website claimed that it''s 100% sure that it's scalable. At the time of providing this repository, I've never seen companies use MobX as their state management in React world.
another graph is:
finally you can find a good sample of MobX at this repo.
- Redux is more structural with all parts seperated but MobX is seeking for simplicity and user-friendly environment by putting everything on sight.
- the coding is easier to be learnt in MobX thatn Redux, but once you followed the structure above I presented and my repo you'll be sure that it's too easy to learn how Redux works.
- Redux has been proved to be scalable even when you have several databases and it seems complicated and tiring to integrate them. But MobX is not that way. It's been claimed that it supports full scalability but I don't think so! Sorry bros...
- The store is more conotrollable in Redux than in MobX
- in Redux you should wait for a component to be mounted (ComponentDidMount() function) but in MobX, it's been rendered before the component loads. Cool yeah but be careful of server CPU, memory usage and bandwidth consumption.
Have Fun!