🔥[v6] Firestore onSnapshot on a single document is always undefined
Issue
When querying a single document using onSnapshot the document and exists property is undefined. Using get instead of onSnapshot works fine. Using onSnapshot on collection works fine too.
firestore().collection('Users').doc(userId).onSnapshot(snapshot=> {
// these are both undefined
console.log(snapshot.exists)
console.log(snapshot.data())
})
--
-
Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [x] Both
-
react-native-firebaseversion you're using that has this issue:"@react-native-firebase/app": "^0.1.2", "@react-native-firebase/auth": "^0.1.2", "@react-native-firebase/firestore": "^0.1.2", "react": "16.8.6", "react-native": "0.60.4",
Thanks for reporting! One line fixes this here. Will get sort a release out.
I'm more confused how the tests didn't pick this up to be honest so I'll be checking that out.
This has now been published in 0.1.3 of the new packages, see https://github.com/invertase/react-native-firebase/issues/2025#issuecomment-519166641.
Thanks