react-firebase-hooks
react-firebase-hooks copied to clipboard
Firestore useOnce hooks don't fetch unless code change causes hot reload
I've come across an issue where the useOnce hooks, for example useCollectionOnce() never loads any results - the loading property just returns true and nothing updates.
import { useCollectionDataOnce } from 'react-firebase-hooks/firestore'
...
const userRef = doc(db, "users", userId);
const projectRef = query(collection(userRef, "projects"));
const [values, loading, error, snapshot] = useCollectionDataOnce(projectRef)
...
However, if I change some code and the app hot-reloads - then the results are retrieved.
Also, if I use useCollectionData() instead, the results are retrieved as expected.
I'm currently using the follow dependencies:
"firebase": "9.7.0",
"next": "12.1.5",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-firebase-hooks": "5.0.3",
Let me know if I can provide any further details to help debug this.
(also reported by @LouisMazorati here: https://github.com/CSFrequency/react-firebase-hooks/issues/77#issuecomment-1116080951)
(p.s. everything else seems to work smoothly - thanks for a fantastic library!)
Same thing happening to me at the moment as I was trying to migrate to firebase 9
Except for next (not using it) I'm using all the same dependencies with the same versions
Same problem here.
@chrisbianca Hi Chris. Sorry for tagging you, but I didn't know who else to contact regarding this. I think this is related to new features in React 18. Could this be taken a look at? Probably just migrating the repo to React 18 helps already
I'm having this same issue and it's pretty breaking. I'll see if I can figure out a solution.
Hi everybody, apologies for the delay in investigating this properly. I've just given this a try and it appears that some of the changes I've made in the newly released v5.1.0 may have inadvertently resolved this issue.
Could I ask you to try v5.1.0 and check whether this has been fixed?
I am closing this issue as it has been confirmed working in #252, but if anybody else is still struggling, please let me know and I can look into it further!