CSFrequency / react-firebase-hooks

React Hooks for Firebase.
Apache License 2.0
3.55k stars 304 forks source link

Next.js with reactStrictMode the useDocumentOnce snapshot is never retrived #262

Closed jasan-s closed 1 year ago

jasan-s commented 1 year ago

with reactStrictMode=true in the next.config.js during development the useDocumentOnce never retrieves the snapshot data with useDocumentOnce , the loading remains true

If i set reactStrictMode=false useDocumentOnce retrieves the data correctly.

my currect hack is the following:

    const [snapshot, loading, error] =
      process && process.env.NODE_ENV === 'development'
        ? useDocument(doc(getFirestore(firebaseApp), 'collection', 'documentId'))
        : useDocumentOnce(doc(getFirestore(firebaseApp), 'collection', 'documentId'))
gBusato commented 1 year ago

Hello guys ! I also had the same issue !

Here are my project informations: "next": "12.2.3", "react-firebase-hooks": "^5.0.3", "firebase": "^9.9.4",

chrisbianca commented 1 year ago

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?

chrisbianca commented 1 year ago

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!