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

question(integrations): how to get firebase instance in v3.*.* since getFirebase() is deprecated #607

Closed
yorickreum opened this issue Jan 4, 2019 · 7 comments

Comments

@yorickreum
Copy link

Since the change to the React context providers (more precisely: #566) the getFirebase() is not available anymore. But how do we access our firebase instance from Redux store now, for example from inside of an action creator?

@yorickreum
Copy link
Author

(See discussion on Gitter.)

@prescottprue
Copy link
Owner

@yorickreum I have been sticking to passing the instance from props.firebase. The current plan is to go expose a middleware and actionCreators so that you can just dispatch the action creators directly with your data. Since it isn't finished yet, I haven't written docs about it yet, but we can discuss more on Gitter. Interested to hear your thoughts!

@yorickreum
Copy link
Author

Sounds good!

Exposing a middleware for thunk would be the same approach as getFirebase() was?

In my particular case I wanted to sign up and send a verification mail directly afterwards. Because I didn't see an actionCreator for sending a verification mail I started to write an own actionCreator, but saw no possibility to access our getFirebase instance... Passing it from the props could be a workaround.

@prescottprue
Copy link
Owner

prescottprue commented Jan 6, 2019

The goal for the middleware is for it to be even more simple than the getFirebase + thunk approach and expose sync action creators for everything instead of wrapped async methods.

All of that aside, auth is exposed so you can call all of the methods directly. The methods that are exposed are wrapped in dispatch since most of them update state, since you don't necessarily need a state update, you can just do a handler similar to in the material example:

import { compose } from 'redux'
import { withHandlers } from 'recompose'
import { withFirebase } from 'react-redux-firebase'

const enhance = compose(
  withFirebase
  withHandlers(
    signupAndEmail: (props) => creds =>
      props.firebase
        .createUser(creds, {
          email: creds.email,
          username: creds.username
        })
        .then(props.firebase.auth().currentUser.sendEmailVerification)
        .then(() => {
          console.log("Signup and email verification successful:")
        })
        .catch(err => {
          console.error("error with signup:", err)
        })
  )
)

@prescottprue prescottprue added this to To Do in v3.0.0 Jan 9, 2019
@prescottprue prescottprue added this to the v3.0.* milestone Jan 15, 2019
@idanlo
Copy link

idanlo commented Jan 25, 2019

any update on this? I want to still have access to firebase instance but use firestoreConnect which I cannot because I use react-redux v6

@prescottprue
Copy link
Owner

@idanlo The version of react-redux-firebase available on the next branch has support for react-redux v6 as mentioned in the installation section of the README. That said, I think there is still an open question of the best way to access the instance within separate actions/middlewares/flows such as thunks/sagas or redux-observable.

Directing #617 here as well since I believe it is a similar question.

For now, I personally have been accessing the instance from props and passing it as necessary (even to separate sagas/thunks if necessary instead of having it passed as part of setup).

@prescottprue prescottprue changed the title [next] How to get firebase instance from Redux store since getFirebase() got deprecated? question(integrations): how to get firebase instance in v3.*.* since getFirebase() is deprecated Feb 8, 2019
@prescottprue
Copy link
Owner

This is also a duplicate of #635, so going to close this and make future updates there. Thanks to everyone for reaching out with thoughts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v3.0.0
  
Done
Development

No branches or pull requests

3 participants