Answer the question
In order to leave comments, you need to log in
What modern state management system is better to choose for a React project from scratch?
Most of the business logic is related to shipping, logistics, and warehouse. The web application is quite large. What modern state management system do you recommend to choose? Let's say somebody practiced Recoil from facebook in production?
Who uses what state management system for React projects?
Answer the question
In order to leave comments, you need to log in
It all depends on the specifics of your project, but from my own experience I can say that storage FP in a project with business logic is often worse than OOP options.
In my projects I usually use the stack from Mobx + tsyringe(DI). Recently added React-Query to this schema. Sometimes it is useful to use MST if your business logic requires some complex data models with their own logic, as well as complex relationships between them. In particular, MST gives you a little more power for designing data models than regular classes with Mobx.
Let me explain my responsibility:
1. Mobx - is responsible for the business logic of the frontend application. No need to shove data getters from the backend there, which you just need to visualize, there is React-Query for this. Since Mobx is based primarily on classes, we can use OOP and related patterns to work with it, building interesting logic from storages and services right on the frontend. For a better understanding of how to cook it correctly, I recommend looking at the backend.
2. React-Query - their website perfectly describes why they are needed, and in any case this tool is designed to complement typical state stores, whether it's at least Mobx, at least Redux, at least something else, I recommend reading it. An excellent tool for working with the state of the application in the case of data that just needs to be taken from the back and displayed.
3. Tsyringe - for me a proven and good tool for working with DI on the front. This is much better than throwing stores into other stores via constructors or global variables. Similarly with the connection to this scheme of services. I must say right away that there is a risk of getting confused in the collector configurations if you use CRA, because both Mobx and Tsyringe use decorators as their basis, and babel digests them with varying success, but if you figure it out, you can configure it)
Again, Redux and OP folks might say that I just don't know how to cook Redux. Indeed, I can't. I tried to touch Redux several times, but I didn’t like it either before I found out about Mobx, or after. I believe that it is possible to develop on it. But the ear can also be scratched with the left hand through the back of the head. For Redux to be productive and efficient, you need to understand how the data is structured and how its reactivity works. It may well be suitable for managing the state of some simple data models, such as forms. But why do we need a central repository for forms?
Mobx in this regard is much simpler and with a good architecture of the project and the application itself, juniors can rarely do something original there, and it’s much more difficult to break performance there. In general, Mobx is trivially more convenient and simpler, but at the same time, it not only does not limit developers in the ability to create complex and elegant solutions, but only helps in this.
Here are my thoughts, I hope it helps
I vote for MobX. From what I tried, this is the most convenient thing. The code turns out to be simple, without any FP brain twists.
I also vote for mobx - a very fast start at the initial level and great opportunities if you dig deeper. Suitable for both small and large projects, you can make one global state, as well as several small ones with or without interaction with each other. The code turns out as you do, mobx almost does not impose its restrictions, as is the case with libraries that implement flux. Plus optimization can be said out of the box. I highly recommend, in all my projects I use only mobx and I'm not going to move anywhere in the near future. True, before that I used only Redux and Apollo
I’m specifically in react recently, I’ve been working for only a year, but I immediately got into a large project. Chose recoil, while satisfied.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question