diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index c562fa5..331b6ef 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -82,14 +82,18 @@ export default function Home() { } } + // Refresh every 15 seconds + useEffect(() => { + const interval = setInterval(() => { + requestLocation(); + }, 15000); + + return () => clearInterval(interval); + }); + // Refresh when screen loads useEffect(() => { - // Refresh every 15 seconds - const interval = setInterval(async () => { - await requestLocation(); - }, 15000); requestLocation(); - return () => clearInterval(interval); }, []); async function DistanceHandler(location: RawLocationType) {