Hook that tracks user geographic location
import { useGeoPosition } from 'use-haki';
const App = () => {
const { position, isResolved } = useGeoPosition();
return (
<section>
<h1>My position:</h1>
{isResolved && <p>longitude: {position.cords.longitude}</p>}
{isResolved && <p>latitude: {position.cords.latitude}</p>}
{isResolved && <p>latitude: {position.cords.timestamp}</p>}
</section>
);
};
const { isResolved, position } = useGeoPosition();
- isLoading
- isResolved
- isRejected
- status
- error
- position - gives GeolocationPosition interface with cords and timestamp