react-firebase-hooks
react-firebase-hooks copied to clipboard
Initial useCollectionDataOnce returns empty
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?
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)
I'm closing this in favour of #231 and #252