Learn React Redux with Hooks and Redux Starter Kit | Hypertext Candy
-
The concept is that:
- It is difficult to manage state using the bucket brigade method, so the state is extracted from the component hierarchy.
- Then, constraints are added to the way the state is manipulated to avoid chaos.
-
Here are the components:
- state:
- An object that represents the current state.
- action:
- An object that instructs the update of the state.
- It only contains a label that is consumed by the reducer, not the actual update content.
- reducer:
- A function that receives the action object and actually manipulates the state.
- action creator:
- A function that generates an action.
- state:
-
It is understandable to wrap the state manipulation instead of directly manipulating the state because it provides constraints.
-
However, it is not clear why there is a need for an action object and a reducer in addition to the function that is in the position of the action creator.
- What would be the problem if the function in the position of the action creator directly manipulated the state?
-
It seems like splitting and abstracting the process more than once might be better.
- It feels like a different approach.
-
For now, I prioritize creating something and learning, so I will consider learning when the bucket brigade method becomes difficult. #React