Corrections

This commit is contained in:
Sébastien Rivière
2025-06-25 17:43:08 +02:00
parent 1bcc05d1c6
commit d25dcfcbc1
19 changed files with 79 additions and 80 deletions

View File

@@ -1,21 +1,23 @@
"use client";
import { useEffect, useState } from "react";
/**
* A hook that returns the location of the user and updates it periodically
* @returns {Object} The location of the user
*/
export default function useLocation(interval) {
const [location, setLocation] = useState();
useEffect(() => {
function update() {
navigator.geolocation.getCurrentPosition((position) => {
setLocation([position.coords.latitude, position.coords.longitude]);
if(interval != Infinity) {
setTimeout(update, interval);
}
}, () => { }, { enableHighAccuracy: true, timeout: Infinity, maximumAge: 0 });
navigator.geolocation.getCurrentPosition(
(position) => {
setLocation([position.coords.latitude, position.coords.longitude]);
if(interval != Infinity) {
setTimeout(update, interval);
}
},
() => { },
{ enableHighAccuracy: true, timeout: Infinity, maximumAge: 0 }
);
}
update();
}, []);