Jake Peterson

Jun 6, 2021

2 min read

What is Redux?

In a previous blog I covered the history of React and the key features it brings to the table, take a look here if you need a refresher. Today I will be covering Redux, and the benefits it can provide to your applications. Redux was created in 2015 by Dan Abramov and Andrew Clark and by design it is typically only to be used when you’re having trouble fitting all your logic into vanilla React.

State Management:

Or should I say a better state management, this it the biggest pro of using redux. Most people recommend making the jump from React to React with Redux when keeping track of the state logic becomes too difficult. Generally this is only seen with larger applications. Let’s dive a little deeper and see how Redux manages the state efficiently.

State Is Read Only: The state can only be changed by writing an action, which is an object that describes how you will change the state. These actions are all logged which makes debugging easier if an error were to arise.

Single Source Of Truth: State logic is not dispersed all throughout your application, instead it is all stored in… the store. Which is an object in Redux that contains your entire applications state.

Reducers: These are functions that take in the previous state, assess an action and update and return the state accordingly.

Cons:

The reducers always return a new state every time, which can lead to an excessive amount of memory used.

There is a lot of boilerplate code, which can be a con for those who enjoy having full control of their code.

Ultimately you have to know when to use Redux, and just because it was built for React it can still be used with other UI layers like Vue, Angular, React Native and more.

Sources: