The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K…

Member-only story

5 Reasons I Started Using Redux With React

Ignacio Nicolas Aguirre
The Startup
Published in
4 min readJan 13, 2021

--

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:

https://www.freecodecamp.org/news/handling-state-in-react-four-immutable-approaches-to-consider-d1f5c00249d5/

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Ignacio Nicolas Aguirre
Ignacio Nicolas Aguirre

Written by Ignacio Nicolas Aguirre

Founder @ Snowball Financial Education www.snowballfinances.com | Javascript Developer

No responses yet