From f2bb5d8381cf28d169ae2f8daaf1b8499d72ff7d Mon Sep 17 00:00:00 2001 From: Mosh Hamedani Date: Thu, 2 Mar 2023 07:56:30 -0800 Subject: [PATCH] Show a spinner while fetching the genres --- src/components/GenreList.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/GenreList.tsx b/src/components/GenreList.tsx index 47ad628..d5b0e0f 100644 --- a/src/components/GenreList.tsx +++ b/src/components/GenreList.tsx @@ -1,9 +1,13 @@ -import { HStack, Image, List, ListItem, Text } from "@chakra-ui/react"; +import { HStack, Image, List, ListItem, Spinner, Text } from "@chakra-ui/react"; import useGenres from "../hooks/useGenres"; import getCroppedImageUrl from "../services/image-url"; const GenreList = () => { - const { data } = useGenres(); + const { data, isLoading, error } = useGenres(); + + if (error) return null; + + if (isLoading) return ; return (