Member-only story
5 Reasons I Started Using Redux With React
And why you should too
I used to dislike Redux a lot. The purpose of this article is to show you the reasons why I changed my mind, why I’m not using Context anymore, and why you should (almost) always use Redux.
1. Forced Best Practices
In React, the concept of state immutability is critical to create error free applications with predictable state changes. If you don’t know how to modify state without mutating it directly, you ought to learn how.
Redux forces you to use pure functions to update state without mutating it directly or, in Redux terms, Reducers. A reducer, in my own words, is like a pure setState() function with directions on what part of the state to modify. These directions are called Actions, which are simple objects that tell Reducers how to modify state. In pseudocode it would look like this:
purelySetState(“MODIFY_USER_ACTION”, {user: {username: “Ignacio”}})
You get to modify global state with best practices.
If you want to read more about state immutability, or how to modify state correctly, you can check out the link below: