Skip to content

Commit 67203ce

Browse files
committed
fix: hydration error due to nested <a> tag in SongCard component
1 parent f4a73ed commit 67203ce

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

web/src/modules/browse/components/SongCard.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { faPlay } from '@fortawesome/free-solid-svg-icons';
44
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
55
import { SongPreviewDtoType } from '@shared/validation/song/dto/types';
66
import Link from 'next/link';
7+
import { useRouter } from 'next/navigation';
78
import Skeleton from 'react-loading-skeleton';
89

910
import {
@@ -14,6 +15,8 @@ import {
1415
import SongThumbnail from '../../shared/components/layout/SongThumbnail';
1516

1617
const SongDataDisplay = ({ song }: { song: SongPreviewDtoType | null }) => {
18+
const router = useRouter();
19+
1720
return (
1821
<div className='flex flex-col gap-2 pb-2 h-full'>
1922
{/* Song image */}
@@ -49,12 +52,18 @@ const SongDataDisplay = ({ song }: { song: SongPreviewDtoType | null }) => {
4952
<Skeleton />
5053
) : (
5154
<>
52-
<Link
53-
href={`/user/${song.uploader.username}`}
55+
{/* TODO: this should be a Link component, but the whole card is a link itself
56+
and the <a> tag can't be nested. Figure out a better way to arrange them (likely
57+
place a link in the image, title and each of the card's components) */}
58+
<button
59+
onClick={(e) => {
60+
e.preventDefault();
61+
router.push(`/user/${song.uploader.username}`);
62+
}}
5463
className='hover:underline'
5564
>
5665
{song.uploader.username}
57-
</Link>
66+
</button>
5867
{' • '}
5968
{formatTimeAgo(new Date(song.createdAt))}
6069
</>

0 commit comments

Comments
 (0)