From 3f8a753abbd5fdde1cc4988d1e763b4dd11d12e8 Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Thu, 2 Mar 2023 21:03:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=B9=E3=81=8C=E3=82=BA=E3=83=AC=E3=81=A6=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=8C=E5=B4=A9=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/menu.js b/menu.js index 4d7d682..2b706c1 100644 --- a/menu.js +++ b/menu.js @@ -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]);