keyの修正と位置情報の取得タイミングの調整
This commit is contained in:
parent
bf016b1c8b
commit
a56dfc7618
@ -93,7 +93,7 @@ export const JRSTraInfo = (props) => {
|
||||
delayData.map((d) => {
|
||||
let data = d.split(" ");
|
||||
return (
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<View style={{ flexDirection: "row" }} key={data[1]}>
|
||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||
{data[0].replace("\n", "")}
|
||||
</Text>
|
||||
|
22
menu.js
22
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);
|
||||
|
Loading…
Reference in New Issue
Block a user