FirebaseExtended / FirebaseExtended/reactfire

Infinite request loop in useFirestoreCollection

Offen
#374 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
v5
Vorherrschende Sprache
TypeScript
Sterne
3.6k
Forks
403
Ø Merge
14 Std. 53 Min.
Gemergte PRs (30 T.)
5

Beschreibung

Hello,

the following code results in an infinite loop when user isn't authenticated aka `user.data` is `undefined`. Is this expected?

```
const user = useUser(undefined, { suspense: true });
const subscriptions = useFirestoreCollection(
firestore
.collection('customers')
.doc(user.data?.uid)
.collection('subscriptions')
```

When something random and non-existent is passed to `doc(myId)`, it throws `Missing or insufficient permissions`, when `null` is passed it throws `Function CollectionReference.doc() cannot be called with an empty path`, however when `undefined` is passed the code goes into an infinite loop and triggers hundreds of requests per second.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.