import { useQuery } from "@tanstack/react-query"; import ArtistLinks from "./ArtistLinks"; import { getTopTracks, imageUrl, type getItemsArgs } from "api/api"; import { Link } from "react-router"; import TopListSkeleton from "./skeletons/TopListSkeleton"; import { useEffect } from "react"; import TopItemList from "./TopItemList"; interface Props { limit: number; period: string; artistId?: Number; albumId?: Number; } const TopTracks = (props: Props) => { const { isPending, isError, data, error } = useQuery({ queryKey: [ "top-tracks", { limit: props.limit, period: props.period, artist_id: props.artistId, album_id: props.albumId, page: 0, }, ], queryFn: ({ queryKey }) => getTopTracks(queryKey[1] as getItemsArgs), }); if (isPending) { return (
Loading...
Error: {error.message}