Ahooks is a Library of React Hooks tools built by the Team of Ants Umi, Taoji ICE and Ali Sports. Based on the React Hooks logic encapsulation capability, aHOOKS provides a number of common Hooks that can greatly reduce code complexity and improve development efficiency. Ahooks aims to be the same React infrastructure as ANTD/Fusion, saving developers a lot of logic rework.

Ahooks predecessor

The predecessor of Ahooks is the ant open source @umiJS /hooks, so it can be said that Ahooks are version 2.0 of Umi Hooks. Umi Hooks has been gaining traction with users since its Release of V1.0 in September 2019. So far umi Hooks has earned 2.2k stars in the community, with 7,000 + NPM weekly downloads and 8,000 + TNPM weekly downloads. In ants, umi hooks have become the standard React hooks library, with 600+ projects counted so far relying on umi hooks. UseRequest has also become a built-in request scheme for UMi3. But the savage growth of umi hooks over the past six months has had some side effects.

  • Some Hooks were not properly designed. Some Hooks were merged later, and some of them were discarded.
  • No API standards are set, resulting in incorrect API format and naming for Hooks.

We’d like to have a chance to resolve both of these issues once and for all.

To build

With the development of React Hooks, teams are trying to use Hooks instead of Class, and Hooks are becoming the dominant way to write the React component. Thanks to the logic encapsulation capabilities of Hooks, common logic can be wrapped to reduce code complexity. Or use Hooks that someone else in the community encapsulates, like react-use, etc. Of course, many teams want to build their own Hooks libraries for a variety of reasons. As you build, however, you can see that the Hooks provided by each Hooks library are pretty much the same, especially the base class Hooks. With the aim of avoiding repetition and the accumulation of UMI hooks, we agreed with the ICE team and Ali Sports team to build a React Hooks tool library based on UMI Hooks, and Ahooks were born.

The status quo

After a month and a half of work, Ahooks are now available in v1.0 and open source at github.com/alibaba/hoo… Warehouse, which you can use safely in a production environment. In contrast to Umi hooks, ahooks have their own API specification, based on which we rewrote all the hooks apis. You can find the updates here. Many other divisions within the group have also been involved in the development of Ahooks, so thank you.

planning

As mentioned earlier, Ahooks aims to be a React infrastructure like ANTD/Fusion. To that end, we are working hard to develop more Hooks, and we expect you to contribute to Ahooks from everyday packages to help them grow.

  • You can submit an RFC and we will help you evaluate the need for Hooks and the specification of the API.
  • You can also submit an idea and we will help you realize it.

In addition to the Hooks library, we are also preparing the React Hooks series of tutorials. It must be admitted that while React Hooks are great, they have a lot of bugs, which we hope to reduce some of the confusion that comes with using Hooks in this series.

You don’t have to read the appendix

  • I recommend the previous articles to help you gain a deeper understanding of UMI hooks/ Ahooks:

    • React Hooks in Ant Financial
    • Umi Hooks – Help Embrace React Hooks
    • UseRequest – Ants Intermediate Standard Request Hooks
  • Why not use react-use instead of building your own React-hooks library?

    • As stated in many previous articles, the react-Use major version is too fast to keep up. The first time I used it was V9, the last time I wrote it was V13, and now IT’s V15. It’s too much trouble to upgrade if it’s used on a large scale.
    • The other thing is that the react-use API design is undefined, which includes Hooks of the same kind.
    • Of course, there is no denying that React-Use is the most popular Hooks library in the community, providing a lot of inspiration for Ahooks.