i’m trying to make an app that count steps and distance and time and i couldn’t find way to get distance in the counter (realtime
) so i want any one to help me how to that .
import {
useEffect,
useState` } from “react”;
import * as Location from “expo-location”;enter code here
export default `useLocation` = () => {
const [location, `setLocation`] = `useState`();
const `getLocation` = async () => {
try {
const { granted } = await `Location`.`requestForegroundPermissionsAsync`();
if (!granted) return;
const {
`coords`: { latitude, longitude },
} = await `Location.getCurrentPositionAsync`();
console.log(latitude, latitude);
setLocation({ latitude, longitude });
} catch (error) {
console.log(error);
}
};
const `updateLocation` = async () => {
try {
await `Locationx.startLocationUpdatesAsync();`
} catch (error) {
console.log(error);
}
};
`useEffect` ( () => {
`getLocation`();
}, []);
return location;
};
enter code here
`