From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Loading and error UI patterns

Loading and error UI patterns

Hello and welcome to lesson number three of this course. In this lesson, we are going to understand how and why we should handle loading and error states and how we can do that gracefully. We discussed this question in the previous lesson as well that why the handling of loading and error states are necessary. Let's take a deep dive into that now. The good user experience is directly equal to a clear feedback going to the user. At each button click or at each event, user is aware what's happening behind the scenes. Whenever we are fetching data from an API, it's very important to show the user a loader Whenever you are calling an API means something is going behind the scenes. So user can get to know that something is getting processed. And if there is an error response coming back from the API, then we should catch the error and we should show the user that what actually went wrong. A bad user experience example can be when your component is stuck for 5 seconds or more and user has…

Contents