Home > database >  How to get id from clicked doc firebase react?
How to get id from clicked doc firebase react?

Time:06-20

I am trying to get the id from a doc when I click a delete button. so the user can delete the post. I got far enough to show the button if the user is the uploader. but, I don't know how to get the id from the clicked document. I tried this:

{auth.currentUser.uid === uploaderId ? (
        <div
          onClick={(e) => {
            if (auth.currentUser.uid === uploaderId) {
              e.stopPropagation();
            deleteDoc(doc(db, "posts", id));
            }
          }}
        >
          <div>
            <button>           
  • Related