react-redux-firebase icon indicating copy to clipboard operation
react-redux-firebase copied to clipboard

Incompetible with SDK v9

Open seyeong opened this issue 4 years ago • 13 comments

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
}

seyeong avatar Oct 16 '21 08:10 seyeong

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

angelsr16 avatar Nov 01 '21 03:11 angelsr16

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'

Xoce51 avatar Dec 30 '21 03:12 Xoce51

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 avatar Jan 31 '22 02:01 mosofsky

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.

mosofsky avatar Jan 31 '22 02:01 mosofsky

The solution offered by @Xoce51 worked for me.

lihleronaldofakudze avatar Mar 08 '22 04:03 lihleronaldofakudze

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

InfiniteCodeMonkeys avatar Mar 20 '22 21:03 InfiniteCodeMonkeys

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

Digital-Coder avatar Mar 24 '22 14:03 Digital-Coder

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

bxie avatar May 14 '22 05:05 bxie

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

billfeng avatar Jul 31 '22 19:07 billfeng

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

BenjaminCastro avatar Aug 02 '22 22:08 BenjaminCastro

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.

jpriollaud avatar Dec 02 '22 22:12 jpriollaud

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.

cabello avatar Dec 03 '22 13:12 cabello

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

florin-bc avatar Jul 13 '23 09:07 florin-bc