re: The Firestore Tutorial for 2020: Learn by Example VIEW POST


This is good but in Unsubscribing from a collection with unsubscribe(), you forgot to return the unsubscribe function that should have done the actual unsubscription. It should be:

function App() {
  const [books, setBooks] = React.useState([]);

  React.useEffect(() => {
    const unsubscribe = firebase
      .onSnapshot((snapshot) => {
        const data = snapshot.docs.map((doc) => ({
          id: doc.id,
+   return unsubscribe
  }, []);

  return books.map(book => <BookList key={book.id} book={book} />)

I mentioned it, but didn't include it. Thanks, fixed.


You are welcome 😉😉😉

Code of Conduct Report abuse