Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 81c2c4d

Browse files
iOS: TypeError: null is not an object (evaluating 'snapshot.documentID') #855
1 parent f3492de commit 81c2c4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/firebase.ios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,9 @@ firebase.firestore.collection = (collectionPath: string): firestore.CollectionRe
22162216

22172217
firebase.firestore.onDocumentSnapshot = (docRef: FIRDocumentReference, callback: (doc: DocumentSnapshot) => void): () => void => {
22182218
const listener = docRef.addSnapshotListener((snapshot: FIRDocumentSnapshot, error: NSError) => {
2219-
callback(new DocumentSnapshot(snapshot.documentID, snapshot.exists, firebase.toJsObject(snapshot.data())));
2219+
if (!error && snapshot) {
2220+
callback(new DocumentSnapshot(snapshot.documentID, snapshot.exists, firebase.toJsObject(snapshot.data())));
2221+
}
22202222
});
22212223

22222224
// There's a bug resulting this function to be undefined..

0 commit comments

Comments
 (0)