4/3/2023 0 Comments React context vs reduxThe first significant “Redux Alert” blinked. So then some global status occurs - user preferences and data which, as it turned out, these departments have in common. The popularity of this approach is so indisputable that often people work with its paradigms without naming it so. The most difficult condition is the certainty that this would not change. Other times, it was a dashboard with sections for departments that do not share anything in common. For instance they were collections of articles with one-route-one-fetch rule. Where their processing and calculations could fit in some simple methods and not overflow the component code. Where the boundaries of data containers were clear and obvious. They were those where I did not even think about using a global store from the draft concept stage. Many projects I did were not using Redux. It is older than React 16.3 - Does my app need Redux? But we all know that the real question is hidden in the context ( □). If you ask literally what to choose, Context or Redux - the answer is RTFM. Redux is for managing the state of the application, Context is for passing props. They seem to clearly define their purpose. These definitions are taken from the docs. “Context provides a way to pass data through the component tree without having to pass props down manually at every level.”.“Redux is a predictable state container for JavaScript apps.”.“O Caesar! These things are beyond all use” But then suddenly, React 16.3 introduced new Context API and here it came again… “now we don’t need Redux at all”. To install it before the complexity of code already written gets bigger than these ugly Redux upper snakes. I request the Redux store before the rest of the team admits that it is necessary. I have participated in this ritual often enough to become smart in advance. ![]() Even from the one who is assigned to implement it. Maybe not followed by an applause, but by not so quieter sounds of laughter and relief. That’s when the second punchline enters - “Ok, let’s switch to Redux”. Sooner or later though, all those smart solutions had to face the real life and deal with the creativity of the project owners. Presentations closed with words “and we don’t need Redux at all” had a guarantee of loud applause. It’s (let’s be honest) too conventional.Īvoiding Redux became craft challenge and proof of an architectural skill. Although they know it and often appreciate its usefulness, they tend not to use it. The attitude towards Redux for fellow React developers is complicated.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |