最右端のデータを消去した場合にクラッシュするバグの修正

This commit is contained in:
harukin-DeskMini 2023-02-01 20:46:03 +09:00
parent 32fb402126
commit 58340bb608

View File

@ -74,6 +74,7 @@ export default function Menu(props) {
useEffect(() => {
getStationList().then(setOriginalStationList);
}, []);
const [locationAndFavorite, setLocationAndFavorite] = useState([]);
useEffect(() => {
if (!favoriteStation) return () => {};
@ -83,6 +84,13 @@ export default function Menu(props) {
setLocationAndFavorite(data);
}, [currentStation, favoriteStation]);
useEffect(() => {
if (!(selectedCurrentStation < favoriteStation.length)) {
setSelectedCurrentStation(favoriteStation.length - 1);
carouselRef.current.snapToItem(favoriteStation.length - 1);
}
}, [favoriteStation]);
const [stationName, setStationName] = useState(undefined);
const [currentStation, setCurrentStation] = useState(undefined);
useEffect(() => {