From 161fdb01ff679601e99e16129c209801dd96af62 Mon Sep 17 00:00:00 2001 From: Enric Bisbe Gil Date: Fri, 16 Dec 2022 16:22:18 +0100 Subject: [PATCH] fix(useGeolocation): Implement immediate option (#2472) --- packages/core/useGeolocation/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/useGeolocation/index.ts b/packages/core/useGeolocation/index.ts index bd8696344f1..1108354b845 100644 --- a/packages/core/useGeolocation/index.ts +++ b/packages/core/useGeolocation/index.ts @@ -23,6 +23,7 @@ export function useGeolocation(options: UseGeolocationOptions = {}) { maximumAge = 30000, timeout = 27000, navigator = defaultNavigator, + immediate = true, } = options const isSupported = useSupported(() => navigator && 'geolocation' in navigator) @@ -61,7 +62,8 @@ export function useGeolocation(options: UseGeolocationOptions = {}) { } } - resume() + if (immediate) + resume() function pause() { if (watcher && navigator)