Skip to content

Commit 1a77424

Browse files
committed
Utilized typed bookClub items, improving type safety and clarity in rendering club cards.
1 parent 341e5f6 commit 1a77424

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/components/ClubCarousel.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
22
import Carousel from "./Carousel";
33
import ClubCard from "./ClubCard";
44
import { useClub } from "../context/ClubContext";
5+
import type { bookClub } from "../utils/bookClub";
56
import "../styles/ClubCarousel.css";
67

78
export default function ClubCarousel() {
@@ -26,15 +27,18 @@ export default function ClubCarousel() {
2627
) : (
2728
<Carousel
2829
data={clubs}
29-
renderItem={(item, index) => (
30-
<div
31-
ref={(el) => { cardRefs.current[index] = el; }}
32-
key={item.id || index}
33-
style={{ height: maxHeight ? `${maxHeight}px` : "auto" }}
34-
>
35-
<ClubCard item={item} index={index} />
36-
</div>
37-
)}
30+
renderItem={(item, index) => {
31+
const club = item as bookClub;
32+
return (
33+
<div
34+
ref={(el) => { cardRefs.current[index] = el; }}
35+
key={club.id || index}
36+
style={{ height: maxHeight ? `${maxHeight}px` : "auto" }}
37+
>
38+
<ClubCard item={club} index={index} />
39+
</div>
40+
);
41+
}}
3842
/>
3943
)}
4044
</div>

0 commit comments

Comments
 (0)