Skip to content

Commit e262fd9

Browse files
authored
Merge pull request #6 from aboutbits/optimized-location-provider
Optimized location provider
2 parents e43c31d + 0dfcf71 commit e262fd9

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/location-provider/LocationProvider.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ export const LocationProvider: React.FC<{
1919
location: null,
2020
})
2121

22-
const updateLocation = async () => {
23-
const position = await getCurrentLocation(highAccuracy).catch(
24-
() => location.location
25-
)
26-
setLocation({ location: position })
22+
const updateLocation = () => {
23+
getCurrentLocation(highAccuracy)
24+
.then((position) => {
25+
setLocation({ location: position })
26+
})
27+
.catch(() => {
28+
setLocation({ location: null })
29+
})
2730
}
2831

2932
useEffect(() => {

0 commit comments

Comments
 (0)