question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore useOnce hooks don't fetch unless code change causes hot reload

See original GitHub issue

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!)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisbiancacommented, Nov 9, 2022

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?

0reactions
chrisbiancacommented, Nov 10, 2022

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found