keyの修正と位置情報の取得タイミングの調整
This commit is contained in:
parent
bf016b1c8b
commit
a56dfc7618
@ -93,7 +93,7 @@ export const JRSTraInfo = (props) => {
|
|||||||
delayData.map((d) => {
|
delayData.map((d) => {
|
||||||
let data = d.split(" ");
|
let data = d.split(" ");
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row" }}>
|
<View style={{ flexDirection: "row" }} key={data[1]}>
|
||||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||||
{data[0].replace("\n", "")}
|
{data[0].replace("\n", "")}
|
||||||
</Text>
|
</Text>
|
||||||
|
22
menu.js
22
menu.js
@ -45,24 +45,28 @@ export default function Menu(props) {
|
|||||||
|
|
||||||
//位置情報
|
//位置情報
|
||||||
const [location, setLocation] = useState(null);
|
const [location, setLocation] = useState(null);
|
||||||
const [errorMsg, setErrorMsg] = useState(null);
|
const [locationStatus, setLocationStatus] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Location.requestForegroundPermissionsAsync().then((data) => {
|
Location.requestForegroundPermissionsAsync().then((data) => {
|
||||||
if (data.status !== "granted") {
|
setLocationStatus(data.status);
|
||||||
setErrorMsg("Permission to access location was denied");
|
|
||||||
return () => {};
|
|
||||||
}
|
|
||||||
Location.getCurrentPositionAsync({}).then((location) =>
|
|
||||||
setLocation(location)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if (locationStatus !== "granted") return () => {};
|
||||||
|
getCurrentPosition();
|
||||||
|
}, [locationStatus]);
|
||||||
|
|
||||||
useInterval(() => {
|
const getCurrentPosition = () => {
|
||||||
Location.getCurrentPositionAsync({}).then((location) =>
|
Location.getCurrentPositionAsync({}).then((location) =>
|
||||||
setLocation(location)
|
setLocation(location)
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
useInterval(() => {
|
||||||
|
if (locationStatus !== "granted") return () => {};
|
||||||
|
getCurrentPosition();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
const [originalStationList, setOriginalStationList] = useState();
|
const [originalStationList, setOriginalStationList] = useState();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList().then(setOriginalStationList);
|
getStationList().then(setOriginalStationList);
|
||||||
|
Loading…
Reference in New Issue
Block a user