Dan Abramov, the creator of Redux recently published an article “You Might Not Need Redux” where he pointed out that developers opt Redux as a de facto when building React apps, without even considering if they actually need it.

Redux is not to be blamed. Like any other library, it offers some tradeoffs like touching three files to achieve simple tasks, describing the state and actions as plain objects and arrays and handling the logic via pure functions. These constraints enable easier debugging, better testability, guarantee the user-interface to be predictable with the state and a lot more out-of-the-box.

But, writing so much to do so less brings in some annoyance and slows down the overall development.

Do we really need a state management library?

Can’t we just define plain ES6 classes as models and store their instances in an array collection without using a library? Yes, we can! But, the problem isn’t the data storage or retrieval.

The real problem is how do we detect data mutation and handle its side-effects. Side-effects of data mutation includes actions like

If we mutate the data using assignment operator (like user.name = “John Doe”), we don’t have a mechanism to detect the change (Object.observe() has been deprecated).

That’s exactly where we need state management libraries.

Redux detects such changes by enforcing data mutation via pure functions called reducers.

How other frameworks solve it?

What are the alternatives to Redux?

this.setState()

React comes with it’s own method of change detection at the component level. If you’re new to React, just stick to this.setState() approach. It works well for small apps. For eg: Simple Todo App

Reactive and Observer patterns with React

Other Flux implementations

My Personal Choice: MobX

[Update Oct 24th 2017] I have started to use mobx-state-tree which is a state container and uses MobX.

Why MobX?

Tradeoffs?

If you choose one library over the other, you gain something and you lose something. Here are some of the tradeoffs MobX offers:

The bottom line

It’s not set in stone that you have to use a specific state management library with React. It’s a personal choice of paradigm which you and your team is comfortable with. The community can be misguiding sometimes. So, before you include a library, think twice about the constraints and tradeoffs the library offers.

Did I miss anything? Feel free to add a response to the article for any correction, opinions and discussions.

If you liked the article, consider recommending it. I am Sanket and we are building NativeBase.io at GeekyAnts.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising &sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!