react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

🔥[v6] Firestore onSnapshot on a single document is always undefined

Open FoodlyEric opened this issue 7 years ago • 2 comments

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-firebase version 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",

FoodlyEric avatar Aug 06 '19 23:08 FoodlyEric

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.

Ehesp avatar Aug 07 '19 07:08 Ehesp

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

Salakar avatar Aug 07 '19 16:08 Salakar