Redux has long been the preferred state management solution for React applications.

However, Redux was criticized for its steep learning curve, cumbersome boilerplate code, complex asynchronous processing, dispatch’s unfriendliness to type detection…

Redux has these issues that every React developer can relate to.

Now, the release of the hooks feature brings more thinking to state management.

This article assumes that you already have a basic understanding of hooks.

What? You haven’t heard of React hooks? Check out the official introduction to hooks here.

It would be elegant and concise to use hooks to organize state inside a component, but does that mean that using hooks doesn’t require global state management?

In my opinion, hooks are most important for:

  1. Make state within components easier to write and maintain
  2. Solve component logic reuse problems

State management, on the other hand, is essentially sharing state across multiple components, or even across the entire application. This is something which hooks cannot solve by themselves.

However.

Hooks are a dimension reduction blow to state management.

Just as the birth and development of the Internet changed the way people communicate with each other, so did hooks influence the React state management scheme.

Many people still focus on “how to make Redux better using hooks APIS”, which is as ridiculous as “how to make the post office more efficient via the Internet”.

In Ali, there is an old saying, “Bring a solution to the problem”. My solution to the react state management problem is reto:

Reto: The React Store is flexible and efficient based on hooks

Reto is the precipitation of React state management scheme since the author did front-end development in Ali for more than a year. I also hope to help more developers who are struggling with state management. Reto costs almost nothing to learn if you already know about hooks, but it is very powerful and flexible. These features and how to use them are described in the links to the documentation above, so I will not repeat them here, just post a simple demo:

Finally, hang up the project’s GitHub link, welcome to contribute code ~ star/fork /

Github.com/awmleer/ret…

If you encounter any problems with Reto, please discuss them in the GitHub Issue