From 72cf36e033ba794db7982befa45f035b62fa6cd2 Mon Sep 17 00:00:00 2001 From: "Alberto Duarte (PWC)" Date: Mon, 9 Oct 2023 17:32:25 +0100 Subject: Changes --- app/components/Genre.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/components/Genre.tsx (limited to 'app/components/Genre.tsx') diff --git a/app/components/Genre.tsx b/app/components/Genre.tsx new file mode 100644 index 0000000..13e7ed2 --- /dev/null +++ b/app/components/Genre.tsx @@ -0,0 +1,24 @@ +import { useEffect, useState } from "react" + +const Genres = ({id}) => { + + const [genres, setGenres] = useState() + + useEffect(() => { + fetch(`https://api.themoviedb.org/3/movie/${id}?api_key=8216fbb9997cd81a67471e6cb5a6f2df`).then((res) => res.json()).then((data) => { + setGenres(data?.genres) + }) + }, [id]) + + return ( +
+ {genres?.map((genre, index) => { + return ( +
{genre.name}
+ ) + })} +
+ ) +} + +export default Genres \ No newline at end of file -- cgit v1.2.3-54-g00ecf