![]() In this case, this creates a hidden dependency, because when refactoring the code, if we remove this dispatch(getUserData()) in only one place, it breaks userData in all other places in the application.Īnd more importantly, the mechanism for maintaining the data that we received from the server is not convenient. Redux creates non-obvious hidden dependencies.Īn example to get the data we get users in the Home.js component:Įnter fullscreen mode Exit fullscreen modeĪnd then having received the data, we use them in many other components ( Transactions, Items, Menu. All this is moved to the global store, and can obfuscate the code by increasing its cohesion.ģ. Requests to the server that are also used in the same module. Conditionally synchronous “handles” that switch private ui behavior in single modules. ![]() The element of rush and deadlines encourages developers to start storing everything in the global store, even if we don't have to. When you're working on a big project with multiple developers. It stands to reason, therefore, that the more code you have to write the buggier your apps will be.» - RICH HARRIS Writing fewer boilerplates not only increases the chance of making fewer mistakes, but also increases the readability of the code - and this is very cool, since you have to read and understand more often than write. Action_type, action creators, Thunks, etc. Switching between different modules with. It's not very cool when you need to develop some kind of module in an existing application, constantly writing a bunch of code. I repeat this is my personal experience with him you can disagree. Now we realize, that the cool thing is that Redux helps to make the architecture - what's wrong with it. And all the asynchronous operations we do are through crutch middleware using mostly Thunk and Saga etc. That is, we have a Store in which we store the State of the entire application, we have Actions that we Dispatch when we need to change the store. Why did Redux take on the many projects by default? My answer is that thanks to Redux we have architecture. Let's take a look at what I personally think are the disadvantages of Redux and why react-query? Until recently, the Web application on the project I'm working on used Redux as the primary state manager, but now we've completely switched to react-query. how on the project we use code generation from Open API in npm package with custom react-query hooks and further we spread the code between two clients of Web i Mobile.react-query as a way to manage application cache.In this article, I would like to address the following aspects:
0 Comments
Leave a Reply. |