mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Re-separate use effect for periodic checking and on load checking in homepage
This commit is contained in:
parent
d072ae456d
commit
a9d7188c67
1 changed files with 9 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue