Fetch data with loading and error state in React Hooks

Andrew Mok
2 min readMar 1, 2020
Photo by Christina Morillo from Pexels

I am using React hooks on the current project that I am working on for a few months. It’s a powerful API, and I would like to show you some useful skills that can be reused in your application.

Data fetching

One common use case is fetching the data from API when mounted. The initial state is empty and you would like to set data to your…

--

--