Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geolocation error is not reset after success #55

Open
piotr-cz opened this issue Jul 8, 2024 · 0 comments
Open

Geolocation error is not reset after success #55

piotr-cz opened this issue Jul 8, 2024 · 0 comments

Comments

@piotr-cz
Copy link

piotr-cz commented Jul 8, 2024

Describe the bug

The Geolocation error is still being returned from both useCurrentPosition and useWatchPosition hooks, even that the position has been read.

To Reproduce

  1. Disable location permission
  2. Use any of the Geolocation hooks
  3. It returns an object { currentPosition: undefined, error: Error }
  4. Enable location permission
  5. Use any of the Geolocation hooks
  6. It reruns and object { currentPosition: GeolocationPosition, error: Error }

Expected behavior
Hooks should not return error when it does not happen

Screenshots

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version 126.0.6478.127

Smartphone (please complete the following information):
Not tested

Additional context
Hooks should reset the error state on success:

 const id = await Geolocation.watchPosition(options || {}, (pos: Position | null, err) => {
-  if (err) {
-    setError(err);
-  }
+  setError(err);
   if (pos) {
     setCurrentPosition(pos);
   }
 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant