So basically please tell me how I should implement the orderBy() function of firestore in onSnapshot() in React. Please help me, guys. I really need your help. If your answering my question please share this code with the orderBy() function implement in it. Here is my code -
onSnapshot(collection(db, "messages"), (snapshot) => {
setMessages(snapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id})))
})
and I have returned this
<div className="chat-app">
{messages && messages.map((msg) => {
return (
<div key={msg.id} className="message">
<img className="img" src={msg.image}></img>
<div className="msg">{msg.message}</div>
</div>
)
} )}