インデックスがズレて表示が崩れていたので修正

This commit is contained in:
harukin-DeskMini 2023-03-02 21:03:35 +09:00
parent 28c58ce83f
commit 3f8a753abb

View File

@ -87,8 +87,13 @@ export default function Menu(props) {
useEffect(() => {
if (!(selectedCurrentStation < favoriteStation.length)) {
setSelectedCurrentStation(favoriteStation.length - 1);
carouselRef.current.snapToItem(favoriteStation.length - 1);
if (favoriteStation.length == 0) {
setSelectedCurrentStation(0);
carouselRef.current.snapToItem(0);
} else {
setSelectedCurrentStation(favoriteStation.length - 1);
carouselRef.current.snapToItem(favoriteStation.length - 1);
}
}
}, [favoriteStation]);