react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

Initial useCollectionDataOnce returns empty

Open shamoons opened this issue 5 years ago • 1 comments

I have:

  const [documents, documentsLoading, documentsError]: [DocumentInterface[], boolean, Error] = useCollectionDataOnce(
    firebase.firestore().collection('documents')
      .where('userId', '==', '1234')
      .orderBy('updatedAt', 'desc')
    ,
    { idField: 'id' }
  )

  useEffect(() => {
    console.log(documentsLoading, documents)
  }, [documents, documentsLoading])

This looks like:

true undefined
false []
true undefined
false [{....}]

So it looks like it's loading twice?

shamoons avatar Jul 23 '20 14:07 shamoons

Howdy,

I'm having a similar issue but related to all of the useXonce hooks. versions in package.json

    "firebase": "^9.7.0",
    "firebase-admin": "^10.1.0",
    "next": "12.1.5",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-firebase-hooks": "^5.0.3",

Refreshing the page does not fetch anything, but making any change in the code / forcing a hot-reload will then show the data.

import { useCollectionOnce } from 'react-firebase-hooks/firestore'

  let ref = firestore
    .collection('users')
    .doc(userId)
    .collection('library')
  const [library, loading, error] = useCollectionOnce(ref)

LouisMarzorati avatar May 03 '22 13:05 LouisMarzorati

I'm closing this in favour of #231 and #252

chrisbianca avatar Nov 09 '22 16:11 chrisbianca