prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

Incompetible with SDK v9 #1145

Open seyeong opened 2 years ago

seyeong commented 2 years ago

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 commented 2 years ago

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

Xoce51 commented 2 years ago

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 commented 2 years ago

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

keywords:

mosofsky commented 2 years ago

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 commented 2 years ago

The solution offered by @Xoce51 worked for me.

InfiniteCodeMonkeys commented 2 years ago

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

Digital-Coder commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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

BenjaminCastro commented 1 year ago

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

jpriollaud commented 1 year ago

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 commented 1 year ago

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 commented 11 months ago

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