Estoy tratando de hacer una aplicación que cuente los pasos, la distancia y el tiempo y no pude encontrar la manera de obtener la distancia en el contador (en realtime ), así que quiero que alguien me ayude a hacerlo.
import { useEffect , useState` } de "reaccionar"; importar * como Ubicación desde "expo-ubicación"; ingrese el código aquí
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`