Firestore useOnce hooks don't fetch unless code change causes hot reload
See original GitHub issueI’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!)
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Firestore Emulators and Hot Code Reloading Error · Issue #390
After a lot of reverse engineering, I figured out this only happens using asyncData or Fetch (default behavior with fetchOnServer to true). It ......
Read more >How to use React Hooks with Firebase Firestore
useEffect Hook accepts two parameters. The first is a function that accepts no parameters and defines what the side effect actually does.
Read more >Values retrieved from firestore only after hot reload in flutter
You have to use setState() to Notify the framework that the internal state of this object has changed. someMethod().then((QuerySnapshot ...
Read more >Firebase JavaScript SDK Release Notes - Google
Fixed a bug that caused Firebase SDKs to throw an error in Firefox browsers ... Changed the networking API to use XHR instead...
Read more >Changelog - Divjoy Docs
It was causing a full page reload after code changes instead of instantly ... We now use React Query and its useQuery hook...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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!