How to use firebase v9 (firestore) docRef.id in react js to map post data?

Viewed 45
  const docRef = await addDoc(collection(db, "posts"), {
    name: "Vishesh",
    description: "Graphic Designer | Web Designer",
    message: input,
    timestamp: serverTimestamp(),
  })
  console.log("Document written with ID: ", docRef.id);

  setInput("");
}

How can i use above docRef.id to map my data with props to get it render on my browser ?

    {posts.map(({ id, data: { name, description, message } }) => (
      <Post
        key={id}
        name={name}
        description={description}
        message={input}
      />

this is the output

0 Answers
Related