fireship-io / next-firebase-course

Next.js + Firebase - The Full Course
next-firebase-course-git-main.fireship.vercel.app
477 stars 218 forks source link

firebase-v9 components/HeartButton.js typo #14

Closed arfemia closed 2 years ago

arfemia commented 2 years ago

getFireStore() should be postRef

Line 9 in components/HeartButton.js (firebase-v9 branch)

// Allows user to heart or like a post

export default function Heart({ postRef }) {
  // Listen to heart document for currently logged in user
  const heartRef = doc(getFirestore(), 'hearts', auth.currentUser.uid);
  const [heartDoc] = useDocument(heartRef);

  ...

  //incorrect, will reference new collection at root
  const heartRef = doc(getFirestore(), 'hearts', auth.currentUser.uid);
  // should be
  const heartRef = doc(postRef, 'hearts', auth.currentUser.uid);
alexookah commented 2 years ago

this was fixed by my recent merge request https://github.com/fireship-io/next-firebase-course/pull/13 that was merged yesterday. I think you can close this issue now

arfemia commented 2 years ago

thank you