Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompetible with SDK v9 #1145

Open
seyeong opened this issue Oct 16, 2021 · 13 comments
Open

Incompetible with SDK v9 #1145

seyeong opened this issue Oct 16, 2021 · 13 comments

Comments

@seyeong
Copy link

seyeong commented Oct 16, 2021

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 use getAuth(firebase) to access the auth object. Due to this change, the init action fails to complete successfully.

Currently auth can be worked around by manually binding auth() to the firebase instance as following:

(firebase as unknown as any).auth = () => getAuth(firebase);

and disabling the following option:

config = {
   enableRedirectHandling: false
}
@angelsr16
Copy link

Do you know how can I work around these compatibility issues for the firestore instance?

@Xoce51
Copy link

Xoce51 commented Dec 30, 2021

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'

@mosofsky
Copy link

Solution offered by @Xoce51 worked for me. I'm going to leave some keywords in this comment to help others find this answer.

keywords:

  • firebase 9
  • Uncaught Error: Firestore must be required and initalized.

@mosofsky
Copy link

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.

@lihleronaldofakudze
Copy link

The solution offered by @Xoce51 worked for me.

@InfiniteCodeMonkeys
Copy link

Do you still get the modular benefits of v9 if you use the compat library?

@Digital-Coder
Copy link

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."

@bxie
Copy link

bxie commented May 14, 2022

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

@billfeng
Copy link

Are there any plans to make react-redux-firebase compatible with Firebase SDK v9?

@BenjaminCastro
Copy link

@Xoce51, thank you! It worked for me also.

@jpriollaud
Copy link

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.

@cabello
Copy link

cabello commented Dec 3, 2022

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.

@florin-bc
Copy link

Bump, when will we be able to use the new modular API from firebase with this library, thus removing the compat code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests