My images are not pulling from shazam core API
This is my Song Card Component:
import { Link } from "react-router-dom";
import { useDispatch } from "react-redux";
import PlayPause from "./PlayPause";
import { playPause, setActiveSong } from "../redux/features/playerSlice";
const SongCard = (song, i) => {
const activeSong = "test";
return (
<div className="flex flex-col w-[250px] p-4 bg-white/5 bg-opacity-80 backdrop-slur-sm animate-slideup rounded-lg cursor-pointer">
<div className="relative w-full h-56 group">
<div
className={`absolute inset-0 justify-center items-center bg-black bg-opacity-50 group-hover:flex ${
activeSong?.title === song.title
? 'flex bg-black bg-opacity-70'
: 'hidden'
}`}
>
<PlayPause />
</div>
<img alt="song_img" src={song.images?.coverart} />
</div>
</div>
);
};
export default SongCard;
This is my Discover Component that's using the Song Card Component
import { Error, Loader, SongCard } from "../components";
import { genres } from "../assets/constants";
import { useGetTopChartsQuery } from "../redux/services/shazamCore";
const Discover = () => {
const { data, isFetching, error } = useGetTopChartsQuery();
const genreTitle = "Pop";
if (isFetching) return <Loader title="Loading Songs.." />;
if (error) return <Error />;
return (
<div className="flex flex-col">
<div className="w-full flex justify-between items-center sm:flex-row flex-col mt-4 mb-10">
<h2 className="font-bold text-3xl text-white text-left">
Discover {genreTitle}
</h2>
<select
onChange={() => {}}
value=""
className="bg-black text-gray-300 p-3 text-sm rounded-lg outline-none sm:mt-0 mt-5 "
>
{genres.map((genre) => (
<option key={genre.value} value={genre.value}>
{genre.title}
</option>
))}
</select>
</div>
<div className="flex flex-wrap sm:justify-start justify-center gap-8">
{data.map((song, i) => (
<SongCard key={song.key} song={song} i={i} />
))}
</div>
</div>
);
};
export default Discover;
React components accept a single props object, you have declared
Songto accept two arguments and named the props objectsong. As such you'd need to destructure the passedsongandiprops from thesongprops object, e.g.song.songandsong.i.It's probably better to rename the props object from
songto the more standardpropsname. Even better to just destructure thesongandiprops directly.Assuming the
song.images.coverartprop value is correct this should be all you need to update.Also, since
i, as a prop, doesn't appear to be referenced or used inSongCardI've removed it.