Thoughts On You Might Not Need Redux Pt.IV
I heavily considered calling this “You Might Not Need Redux, Redux”, but was able to resist the pun.
In Dan Abramov’s great little article You Might Not Need Redux, the third trade off with Redux is listed as:
- Describe the logic for handling changes as pure functions.
This might be the biggest trade off with the widest implications and side effects — despite talking about pure functions.
Redux works through the usage of Actions, Reducers, and a Store. The three trade offs listed by Abramov in his article have to individually do, vaguely, with one of these three parts of the Redux pattern. The final trade really relates the most directly to Actions. Without getting into the details of reducers, essentially Redux Actions say how state changes will go down, if an item needs to get removed or added to a list an Action will be written for each. All Actions are pure functions and thus have no side effects, do not mutate data objects, and merely return some totally new piece of data. Suddenly, local pieces of data and state can’t be manipulated, things that need to change later on in the lifecycle of a component have to rely on these pure functions and little changes, like sizing of a div, or the nature of some background const, is very hard to do and requires a developer to go up to an Action to change something that could be more easily understood if it was just happening locally in a component.
