

To a certain extent, it will become more and more difficult to calculate the state of the application.

MOBX VS REDUX HOW TO
Friendly reminder: please use it before you go deep into mobx and redux setState()。 Finally, if you already have an application using mobx or Redux, I will give you more understanding on how to refactor from one state management library to another. Third, I will show the beginners of react ecology how to learn the state management of react. Second, I will roughly describe the similarities and differences between them. After all, when we write react, we only use setState()Or when writing other spa frameworks setState()Similar methods can also be done well. But I want to give you more details: first, I want to briefly review what problems the state management library has solved for us. What will this article say? If you are not going to read such a long article (TLDR: Too long, didn’t read), you can look at the catalogue. Now I can use them very freely and explain their usage. When I found that mobx could replace Redux, I took the time to reconstruct mobx from redux. I used it in early 2016 React + ReduxWrote a fairly large application. But in most cases, you can replace react with angular, Vue or others. Most articles use react to introduce the usage of mobx and redux. What I am writing now is to solve the confusion between the two state management libraries Redux and mobx. Whenever there is a choice, people will wonder what is the best way to solve the problem. This problem does not just appear on Redux and mobx.

It seems that the community is naturally confused about what to choose to replace redux。 Developers are not sure which solution to choose. I used it a lot last year Redux, but I’ve been using it lately MobxTo do state management. For example, the state of a todo app might look like this: )Īctions are anything that modifies the state.Original address: Redux or MobX: An attempt to dissolve the Confusion Imagine your app’s state is described as a plain object. The state of your whole application is stored in an object tree within a single store. Reducers are seen as the most important of the three concepts.

This way, your state is not mutated in an irregular manner. They copy the current state, modify it based on actions emitted, and return a new state. Reducers do not mutate the current state. To alter the state of your application, reducers listen to actions emitted and returns a new state based on the action performed. The store holds the state, actions represent intents to change the state, and reducers specify how the application's state changes in response to actions. Redux revolves around three concepts: the store, the reducer, and actions. With this library, the state is kept in one location (the store) and made a read-only entity. Redux, empowers its users to write applications that can work in a different environment (no matter the client, server or native), consistent behavior and east testing. Redux strictly abides by the single source of truth principle. Redux is the most popular state management solution for React apps.
