Skip to content

Commit 24ceb8b

Browse files
committed
fix: carousel 하단 버튼 초기 렌더링 시 보이도록 상태 관리 수정
1 parent 6c8ae5d commit 24ceb8b

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "LinKU",
44
"description": "건국대학교 학생들을 위한 건국대, 건대 교내외 페이지 모음 링쿠, LinKU",
5-
"version": "1.1.36",
5+
"version": "1.1.37",
66
"action": {
77
"default_popup": "index.html"
88
},

public/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "LinKU",
44
"description": "건국대학교 학생들을 위한 건국대, 건대 교내외 페이지 모음 링쿠, LinKU",
5-
"version": "1.1.36",
5+
"version": "1.1.37",
66
"action": {
77
"default_popup": "index.html"
88
},

src/components/ImageCarousel.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ import { IMAGE_URL } from "@/constants/URL";
77

88
const ImageCarousel = () => {
99
const [imageList, setImageList] = useState<BannerItemType[]>([]);
10+
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true }, [Autoplay()]);
11+
const [selectedIndex, setSelectedIndex] = useState(0);
12+
const [scrollSnaps, setScrollSnaps] = useState<number[]>([]);
13+
1014
useEffect(() => {
1115
getBannersAPI().then((data) => {
1216
setImageList(data.banners);
17+
if (emblaApi) {
18+
setScrollSnaps(emblaApi.scrollSnapList());
19+
}
1320
});
14-
}, []);
15-
16-
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true }, [Autoplay()]);
17-
const [selectedIndex, setSelectedIndex] = useState(0);
18-
const [scrollSnaps, setScrollSnaps] = useState<number[]>([]);
21+
}, [emblaApi]);
1922

2023
const scrollPrev = useCallback(
2124
() => emblaApi && emblaApi.scrollPrev(),
@@ -43,7 +46,7 @@ const ImageCarousel = () => {
4346
return () => {
4447
emblaApi.off("select", onSelect);
4548
};
46-
}, [emblaApi, onSelect, imageList]);
49+
}, [emblaApi, onSelect]);
4750

4851
return (
4952
<div className="embla relative h-[86px]">

0 commit comments

Comments
 (0)