Build a Dynamic Skeleton Loader for Course Cards
In modern web applications, perceived performance is as crucial as actual performance. When fetching data from an API, displaying a blank screen or a loading spinner can lead to a poor user experience. Skeleton loaders address this by providing a visual placeholder that mimics the layout of the content being loaded, giving users immediate feedback and making the waiting time feel shorter. This problem focuses on implementing a dynamic skeleton loader for a list of course cards, a common pattern in educational platforms like Upgrad.
Your task is to create a set of React components that display course information and a corresponding skeleton loader. You will simulate a data fetching delay and dynamically switch between the skeleton loader and the actual content.
CourseCard component: This component will receive course data (title, instructor, duration, rating, image) and render it in a visually appealing card format.CourseCardSkeleton component: This component should visually mimic the layout of the CourseCard but use placeholder shapes (e.g., rectangles, circles) instead of actual content. It should not receive any props.App.tsx: In the main App component, use the provided mock course data and a simulated loading state (using setTimeout). Conditionally render a list of CourseCardSkeleton components while isLoading is true, and switch to rendering actual CourseCard components once isLoading becomes false.CourseCardSkeleton should include a subtle animation (e.g., a shimmer or pulse effect) to indicate active loading.CourseCard's structure. For instance, if CourseCard has an image at the top, the skeleton should have a placeholder rectangle of similar dimensions at the top. Text lines should be replaced by varying lengths of grey rectangles.CourseCard component correctly renders all provided course details (image, title, instructor, duration, rating).CourseCardSkeleton component accurately mimics the visual structure and proportions of the CourseCard.CourseCardSkeleton components when isLoading is true.CourseCard components with actual data when isLoading is false.CourseCardSkeleton includes a noticeable, smooth loading animation (shimmer or pulse).CourseCards or CourseCardSkeletons are displayed in a grid layout.Constraints
react-loading-skeleton).setTimeout as provided in the starter code.aria-live) beyond basic semantic HTML.CourseCard and CourseCardSkeleton components are structured and how they interact.useState and useEffect to manage the loading state and simulate data fetching.Loading editor...