インデックスがズレて表示が崩れていたので修正
This commit is contained in:
5
menu.js
5
menu.js
@@ -87,9 +87,14 @@ export default function Menu(props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!(selectedCurrentStation < favoriteStation.length)) {
|
if (!(selectedCurrentStation < favoriteStation.length)) {
|
||||||
|
if (favoriteStation.length == 0) {
|
||||||
|
setSelectedCurrentStation(0);
|
||||||
|
carouselRef.current.snapToItem(0);
|
||||||
|
} else {
|
||||||
setSelectedCurrentStation(favoriteStation.length - 1);
|
setSelectedCurrentStation(favoriteStation.length - 1);
|
||||||
carouselRef.current.snapToItem(favoriteStation.length - 1);
|
carouselRef.current.snapToItem(favoriteStation.length - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, [favoriteStation]);
|
}, [favoriteStation]);
|
||||||
|
|
||||||
const [stationName, setStationName] = useState(undefined);
|
const [stationName, setStationName] = useState(undefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user