diff --git a/components/ActionSheetComponents/JRSTraInfo.js b/components/ActionSheetComponents/JRSTraInfo.js index 9fb0d7e..6cb2b17 100644 --- a/components/ActionSheetComponents/JRSTraInfo.js +++ b/components/ActionSheetComponents/JRSTraInfo.js @@ -93,7 +93,7 @@ export const JRSTraInfo = (props) => { delayData.map((d) => { let data = d.split(" "); return ( - + {data[0].replace("\n", "")} diff --git a/menu.js b/menu.js index 32cc2cf..fe31a17 100644 --- a/menu.js +++ b/menu.js @@ -45,24 +45,28 @@ export default function Menu(props) { //位置情報 const [location, setLocation] = useState(null); - const [errorMsg, setErrorMsg] = useState(null); + const [locationStatus, setLocationStatus] = useState(null); useEffect(() => { Location.requestForegroundPermissionsAsync().then((data) => { - if (data.status !== "granted") { - setErrorMsg("Permission to access location was denied"); - return () => {}; - } - Location.getCurrentPositionAsync({}).then((location) => - setLocation(location) - ); + setLocationStatus(data.status); }); }, []); + useEffect(() => { + if (locationStatus !== "granted") return () => {}; + getCurrentPosition(); + }, [locationStatus]); - useInterval(() => { + const getCurrentPosition = () => { Location.getCurrentPositionAsync({}).then((location) => setLocation(location) ); + }; + + useInterval(() => { + if (locationStatus !== "granted") return () => {}; + getCurrentPosition(); }, 5000); + const [originalStationList, setOriginalStationList] = useState(); useEffect(() => { getStationList().then(setOriginalStationList);