最右端のデータを消去した場合にクラッシュするバグの修正
This commit is contained in:
parent
32fb402126
commit
58340bb608
8
menu.js
8
menu.js
@ -74,6 +74,7 @@ export default function Menu(props) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList().then(setOriginalStationList);
|
getStationList().then(setOriginalStationList);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const [locationAndFavorite, setLocationAndFavorite] = useState([]);
|
const [locationAndFavorite, setLocationAndFavorite] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!favoriteStation) return () => {};
|
if (!favoriteStation) return () => {};
|
||||||
@ -83,6 +84,13 @@ export default function Menu(props) {
|
|||||||
setLocationAndFavorite(data);
|
setLocationAndFavorite(data);
|
||||||
}, [currentStation, favoriteStation]);
|
}, [currentStation, favoriteStation]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!(selectedCurrentStation < favoriteStation.length)) {
|
||||||
|
setSelectedCurrentStation(favoriteStation.length - 1);
|
||||||
|
carouselRef.current.snapToItem(favoriteStation.length - 1);
|
||||||
|
}
|
||||||
|
}, [favoriteStation]);
|
||||||
|
|
||||||
const [stationName, setStationName] = useState(undefined);
|
const [stationName, setStationName] = useState(undefined);
|
||||||
const [currentStation, setCurrentStation] = useState(undefined);
|
const [currentStation, setCurrentStation] = useState(undefined);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user