Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Geolocation error is not reset after success

Aperta
#55 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react, typescript
Ambito
mobile-dev

Direzione di ricerca

Inizia dal callback Geolocation.watchPosition negli hook useCurrentPosition e useWatchPosition, quindi riproduci la sequenza di disabilitazione e ripristino dei permessi descritta nell’issue. Il lavoro è completato quando una posizione ottenuta correttamente non lascia più l’errore precedente nello stato restituito dall’hook.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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);
   }
 });
Lingua principale
TypeScript
Stelle
267
Fork
24
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di capacitor-community/react-hooks

Tutte le issue di capacitor-community/react-hooks

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.