const messagesRef = collection(db, 'messages')
const q = query(messagesRef, orderBy('createdAt'), limit(25))
const [messages, loading] = useCollectionData(q)
// messages print fields of documents without id
Need to get Id of documents, I guess there's a way to pass options in that hook but dk how.
If there's no way to get Id using that hook then what's the option?
Well, I changed hook to useCollection
const [messages, loading] = useCollection(q)
This solved a problem.
useCollectionData only returns fields of documents, while useCollection returns snapshot with every document and id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With