Open seyeong opened 2 years ago
Do you know how can I work around these compatibility issues for the firestore instance?
Hello,
I faced the same issue, but you can use a workaround with firebase import:
In your initialization file use:
import firebase from 'firebase/compat/app'
import 'firebase/compat/auth'
import 'firebase/compat/firestore'
Solution offered by @Xoce51 worked for me. I'm going to leave some keywords in this comment to help others find this answer.
keywords:
Note this caveat that the compat libraries may not work in Firebase 10 or 11:
Keep in mind: the compat libraries are a temporary solution that will be removed completely in a future major SDK version (such as version 10 or version 11). Your ultimate goal is to remove compat code and keep only version 9 modular-style code in your app.
The solution offered by @Xoce51 worked for me.
Do you still get the modular benefits of v9 if you use the compat library?
Do you still get the modular benefits of v9 if you use the compat library?
Unfortunately no. "Compat libraries have little to no size or performance advantages over their version 8 counterparts."
Solution offered by @Xoce51 also worked for me. Adding more keywords for visibility, b/c incompatibility was perplexing me for awhile!
When trying to call firebase.createUser()
, I got the following error:
Uncaught TypeError: firebase.auth is not a function
The solution was to replace my import from firebase/auth
to firebase/compat/auth
in the file where I initialized my firebase app instance (index.tsx).
Are there any plans to make react-redux-firebase compatible with Firebase SDK v9?
@Xoce51, thank you! It worked for me also.
Heads up for anyone wondering, you can use v9 Modular elsewhere in your app and then just have your RRF component do it's own initialization per the above comments. We saw no conflicts, which is fantastic.
Once RRF supports v9 Modular you may be able to just import your existing Firebase instead of re-initializing with Compat.
Confirmed that approach works as well. Keep in mind however that you get no benefits in bundle size by using this approach. Using modular v9 should reduce bundle size, as Firebase is a chunky boy, but once you load the entire thing to init React Redux Firebase, then you are back to v8 footprint.
Bump, when will we be able to use the new modular API from firebase with this library, thus removing the compat code?
SDK migration guide: https://firebase.google.com/docs/web/modular-upgrade
The way that modules are accessible have been changed in v9. For example,
firebase.auth()
does not exist anymore and you need to usegetAuth(firebase)
to access the auth object. Due to this change, theinit
action fails to complete successfully.Currently auth can be worked around by manually binding
auth()
to the firebase instance as following:and disabling the following option: