File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 22import React , { useEffect , useState } from "react" ;
33
44export 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}
You can’t perform that action at this time.
0 commit comments