Understanding Hooks Part 5 — Custom Hook

What’s behind the legendary Hooks? From time to time, I wonder.

Starting Part 4 the generic feature of a Hook is revealed. In this Part 5 we’d like to introduce a custom hook useAync to demonstrate how useState and useEffect can be served as the building blocks.

Say we want to fetch a call fn, wait for the data while loading without blocking the render.