A React hook for asynchronous state

Modern day user interfaces are expected to handle asynchronous state changes. Whether it is server communication, offloaded computations, or permission-based browser APIs, developers need to convey to their customers what is happening, has happened, is going to happen, and what went wrong.

A common pattern arises in React applications, where — in addition to the asynchronous functionality — the component’s local state must update for each step in the state machine: uninitiated, pending, fulfilled, and rejected.