Shouldn’t state management be a solved problem by now? Intuitively, developers seem to know a hidden truth: state management seems harder than it needs to be. In this article, we’ll explore some questions you’ve probably been asking yourself:

Do you need a library for state management?

Is the popularity of Redux deserved? Why or why not?

Could we make a better state management solution? If so, how?

Does state management need a library?

Being a front-end developer is not just about moving pixels around; the real art of development is knowing where to store your state. Short answer: it’s complicated, but not that complicated.

Let’s take a look at our options when using a component-based view framework/library like React:

1. Component State

State that exists inside of a single component. In React, think state updated with setState .

2. Relative State

State passed from a parent to a child. In React, think props passed as properties on a child component.

3. Provided State

State held in a root provider, and accessed by a consumer somewhere down the component tree, regardless of proximity. In React, think of the context API .

A lot of state belongs in the view, as it reflects the UI. But what about all the other code that reflects your underlying data and logic?

Putting everything inside of views can lead to a poor separation of concerns: it ties you to a javascript view library, it makes code harder to test, and perhaps the greatest annoyance: you have to continually think and readjust where you store your state.

State management becomes complicated by the fact that designs change and it’s often hard to tell which components will need which state. The most straightforward choice is to just provide all of the state from the root component, at which point you’re probably better off just going with next option.

4. External State

State can be moved outside of your view library. The library can then “connect” using the provider/consumer pattern to keep in sync.

Perhaps the most popular state management library is Redux. Over the past two years, it has grown massively in popularity. So why so much love for a simple library?

Is Redux more performant? No. It gets slightly slower with each new action that must be handled.

Is Redux simpler? Certainly not.

Simple would be pure javascript: