more of an aspiration than a claim

Choosing React State Management Libraries

Check out the MacBook prices

One of the problems with React is making a choice between the many third party library options to use with React.

State management was dominated by the Redux state management library after the Flux wars with MobX perhaps a distant second (which I preferred over Redux).

In more recent times, new thoughts have emerged. Redux is still popular and has been through different variations itself. redux-toolkit is perhaps the most recommended way at the moment for Redux users and looks much nicer than the redux I first started trying to use.

Redux still dominates, but a few new players have started getting some attention in the React world.

State library comparisons

I found this video by Jack Herrington a great overview of some of the libraries and the different types of React state management libraries avaialable.

There is also a GitHub repo that has code examples of 20 different React state management libraries, which is a lot more than is detailed in the above video.

[akita vs jotai vs mobx vs recoil vs redux vs valtio vs xstate vs zustand](https://www.npmtrends.com/akita-vs-jotai-vs-mobx-vs-recoil-vs-valtio-vs-xstate-vs-zustand-vs-redux on npmtrends)

  • you might want to remove redux from this comparison if you are interested in the others to get a better view as redux has a lot more downloads.

Flux libraries

As mentioned, redux-toolkit is a very popular helper for redux, the most popular flux implemenation.

Another library that is less verbose and has gained popularity is zustand. Zustand uses react hooks, doesn’t need context providers. Even if you just check out the link for zustand as it is pretty cool!

Bi-directional state management

I found valtio particularly interesting as it seems a cleaner solution than MobX looking at the examples and kind of reminds me of Vue (which I have been using lately). Check out Pinia in Vue if you are using that as it will become Vuex 5 and seems really clean.

Atomic State management

Atomic state management seems to be a popular new technique, with Recoil being invented by a Facebook/Meta? employee Dave McCabe. Jotai is inspired by Recoil and some people prefer it over Recoil.

State machine state management

xstate to model state machines is a popular state management library in React. There is also a nifty looking tool that shows a visualisation of your state machine in realtime.

When to use each

jotai vs valtio

I had some problems with the Logitech MX Master 3S Mouse with an M1 MacBook Pro, but I had better luck with a Logitech G502 X Mouse