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

[v2] Getting `TypeError: firebase.auth is not a function` when passing a Firebase app instance #249

Closed
nicolasgarnier opened this Issue Aug 23, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@nicolasgarnier

nicolasgarnier commented Aug 23, 2017

I'm getting the following error when passing a firebase App instance rather than the firebase library to reactReduxFirebase :

TypeError: firebase.auth is not a function
    at Object.init (/Users/nivco/Documents/workspace/friendlypix-web-react/node_modules/react-redux-firebase/lib/actions/auth.js:162:12)

Here is how to reproduce the issue:

import firebase from 'firebase';

const firebaseApp = firebase.initializeApp(fbconfig);

// ...

export const store = createStore(
  combineReducers({
    ...reducers,
    firebase: firebaseStateReducer
  }),
  compose(
    applyMiddleware(thunk.withExtraArgument(getFirebase)),
    reactReduxFirebase(firebaseApp)
  )
);

This code, however, works (where I pass the firebase lib rather than a Firebase App instance):

import firebase from 'firebase';

const firebaseApp = firebase.initializeApp(fbconfig);

// ...

export const store = createStore(
  combineReducers({
    ...reducers,
    firebase: firebaseStateReducer
  }),
  compose(
    applyMiddleware(thunk.withExtraArgument(getFirebase)),
    reactReduxFirebase(firebase)
  )
);

However the best practice should be to pass a firebase App instance rather than the firebase library. The app Instance (firebaseApp in the code) should work similarly, it definitely has an auth() function so I'm not sure why we're getting this error.

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Aug 23, 2017

Owner

Yup, you are right. Going to look into it.

The initial thought was to pass the whole library since there could be multiple app instances, but I agree it would be best to pass the instance. It seems like it would make it easier to run firebase apps side by side in the same store (currently when doing this users have stored other apps under different store keys).

Owner

prescottprue commented Aug 23, 2017

Yup, you are right. Going to look into it.

The initial thought was to pass the whole library since there could be multiple app instances, but I agree it would be best to pass the instance. It seems like it would make it easier to run firebase apps side by side in the same store (currently when doing this users have stored other apps under different store keys).

@prescottprue prescottprue added this to the v2.0.0 milestone Aug 24, 2017

@prescottprue prescottprue self-assigned this Aug 24, 2017

prescottprue added a commit that referenced this issue Aug 24, 2017

Support lazy/module loading - #249, #250
* Only existing parts of Firebase library are called to support
lazy/module loading
* enableRedirectHandling no longer needs to be set as false if not in
http environment such as SSR (firebase redirect only works if
location.protocol is http or https)

@prescottprue prescottprue referenced this issue Aug 24, 2017

Merged

v2.0.0 beta.7 #252

3 of 3 tasks complete

prescottprue added a commit that referenced this issue Aug 24, 2017

v2.0.0 beta.7 (#252)
* fix(reducer): allow setting paths ending in numbers - #248
* feat(auth): make signInWithCredential not dependent on provider - #247
* `signInWithCustomToken` no longer decodes token internally for profile data (`profileFactory` should be used) - #244
* Removed `jwt-decode` as a dependency (not needed since auth token no longer decoded internally)
* Support lazy/module loading - #249, #250 
* Updated SSR docs to include notes about `enableRedirectHanlding: false` - #251
* Updated Roadmap with detection of non-http environments
@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Aug 24, 2017

Owner

As I mentioned in #250, v2.0.0-beta.7 includes support for passing just the app instance.

Owner

prescottprue commented Aug 24, 2017

As I mentioned in #250, v2.0.0-beta.7 includes support for passing just the app instance.

@nicolasgarnier

This comment has been minimized.

Show comment
Hide comment
@nicolasgarnier

nicolasgarnier Aug 24, 2017

Sweet! Thanks so much @prescottprue

nicolasgarnier commented Aug 24, 2017

Sweet! Thanks so much @prescottprue

@nicolasgarnier

This comment has been minimized.

Show comment
Hide comment
@nicolasgarnier

nicolasgarnier Aug 24, 2017

works like a charm! 👍

nicolasgarnier commented Aug 24, 2017

works like a charm! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment