Skip to content

Commit a4ed4b8

Browse files
committed
watch update
1 parent e72fd61 commit a4ed4b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/app/floorplan/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import React, { useEffect, useState } from "react";
33

44
export default function Page() {
5-
const [position, setPosition] = useState<GeolocationPosition>();
5+
const [positions, setPositions] = useState<GeolocationPosition[]>([]);
66

77
useEffect(() => {
88
const watchID = navigator.geolocation.watchPosition(
99
(position) => {
10-
setPosition(position);
10+
setPositions([...positions, position]);
1111
},
1212
() => { },
1313
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }
@@ -16,9 +16,9 @@ export default function Page() {
1616
return () => {
1717
navigator.geolocation.clearWatch(watchID);
1818
}
19-
}, [setPosition]);
19+
}, [setPositions]);
2020

2121
return (<div>
22-
{JSON.stringify(position)}
22+
{JSON.stringify(positions)}
2323
</div>);
2424
}

0 commit comments

Comments
 (0)