5 Reasons to Learn Redux

Why you should rethink how to build single-page apps

When we develop single-page Javascript applications, we have to deal with state management. Managing the state is so critical that a poor solution can jeopardize an application. Because of problems like that the guys from Facebook created Flux.

Flux is the application architecture that Facebook uses for building web applications. It complements React’s composable view components by utilizing a unidirectional data flow.

According to Redux creator Dan Abramov, it is not that different from Flux.

Overall it’s the same architecture, but Redux is able to cut some complexity corners by using functional composition where Flux uses callback registration. It’s not fundamentally different, but I find it that Redux makes certain abstractions easier, or at least possible to implement, that would be hard or impossible to implement in Flux. Redux is a predictable state container that takes the best parts of the Flux architecture to its logical conclusion.

Redux attempts to make state mutations more predictable by imposing certain restrictions on how and when updates can happen. These restrictions are reflected in the three principles of Redux.

So, why should I learn Redux?

Well, when we develop apps we always look at some patterns to provide scalability and maintainability. While our apps grow, complex problems pop up like maintain session variables or even reactive variables, in many cases you spend a lot of time troubleshooting these state things.

Imagine that a view can update a model and this model can update another model, which updates another view, that might update another model. Finally, you get crazy, because you no longer can understand what happens in your app.

Why??????????

1. Predictable development

Redux can easily predict the way of states behave with the state container. While the state of your whole application is stored in an object tree within a single store, the only way to mutate this state is to emit an action that is an object describing what happened. Finally, to specify how the state is transformed by actions, you have to write pure function reducers. This way Redux provide an easily and maintainable way to develop apps.

You can check the three principles of Redux. But is highly recommended that you read the Redux documentation.

2. Development Tools

Redux enables tools like hot reloading, time travel, record & replay by default. It also means we can easily implement complex features like undo/redo.

3. Easy to test

Tests with Redux are easy. They can be broken down into 4 tiers:

Action Tests Reducer Tests Middleware Tests Component Tests

Because most of the Redux code you write are functions, and many of them are pure, they are easy to test without mocking.

4. Redux is popular

It has 17k+ starts on Github in less than 6 months. It’s not only that, even the creator of Flux Jing Chen said “Love what you’re doing with Redux”.

Yeahh!

5. Free Resources to Learn Redux

Connect