Skip to content

Commit

Permalink
Render spinner when genrelist is loading
Browse files Browse the repository at this point in the history
  • Loading branch information
KavetiRohith committed Sep 11, 2023
1 parent f71f76a commit 78547f9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/GenreList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { HStack, Image, List, Text, ListItem, Button } from "@chakra-ui/react";
import {
HStack,
Image,
List,
Text,
ListItem,
Button,
Spinner,
} from "@chakra-ui/react";
import useGenres, { Genre } from "../hooks/useGenres";
import getCroppedImageUrl from "../services/image-url";

Expand All @@ -7,7 +15,9 @@ interface GenreListProps {
}

const GenreList = ({ onSelectGenre }: GenreListProps) => {
const { genres, error } = useGenres();
const { genres, isLoading, error } = useGenres();
if (isLoading) return <Spinner />;

return (
<>
{error && <Text>{error}</Text>}
Expand Down

0 comments on commit 78547f9

Please sign in to comment.