Closed taylorchance closed 2 years ago
Actually it's returning the document id in the previous version (I don't know which version start returning undefined
id, but I use version 4.0.1 and it's returning the full document id!)
As of react-firebase-hooks
v5, the library relies on Firestore's built in FirestoreDataConverter functionality rather than the bespoke method used previously. This gives access to the underlying doc id and ref fields if required.
I've added an example to the docs here: https://github.com/CSFrequency/react-firebase-hooks/tree/master/firestore#transforming-data
Let me know if there are any issues
@chrisbianca Thank you for the example in the docs. Do you have an example for JS, besides TS as well? I am struggling as well to include the Id by reading from the snapshot. Thank you so much!
@LGR3VE the example for JS should be identical, you'll just need to drop the type annotations
It would be helpful to add an option that useCollectionData also returns the doc id as well.