Giter Club home page Giter Club logo

Comments (12)

karltaylor avatar karltaylor commented on August 16, 2024 5

If anyone came across this, this is working. And you can setup using both getFirebase and getFirestore by passing in multiple arguments to applyMiddleware.

const store = createStore(
  rootReducer,
  compose(
    applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })),
    reactReduxFirebase(firebase, {
      userProfile: 'users',
      enableLogging: false
    }),
    reduxFirestore(firebase),
    ...enhancers
  )
)

and within your thunk:

export default function foo () {
  return function (dispatch, getState, { getFirebase, getFirestore }) {
    const firebase = getFirebase()
    const firestore = getFirestore()
    // do some magic thanks to @prescottprue
  }
}

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

redux-firestore does not yet support using through getFirebase from react-redux-firebase. This is because getFirebase points to the firebase instance that lives on store.firebase, which is added by the reactReduxFirebase store enhancer.

reduxFirestore is the equivalent store enhancer for redux-firestore, so that would need its own getFirestore, or getFirebase will need to be extended.

withFirestore or firestoreConnect are available which provide firestore as a prop so that you can call it from there. That said, this will for sure be ironed out.

from redux-firestore.

jacobfunch avatar jacobfunch commented on August 16, 2024

Thank you for a quick reply. Is there another temporary solution than using withFirestore or firestoreConnect? I tried to make a lookup from within a saga after an action and based on the result route somewhere.

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

There are two options:

  • use store.firestore from your redux store by passing this.context.store.firestorein thepayloadof the action youdispatchto call your saga (make sure you providecontextTypes`)
  • set your own firebase listener and dispatch the @@react-redux-firebase/SET action (importable) in the callback so that the data is written into the store

Personally I would go for the first so that it is easy to switch out. That said, I will prioritize getting something out for it (either placing them on getFirebase or making a getFirestore).

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

v0.1.0-beta was released with getFirestore in there. Let me know if it does not work as expected.

from redux-firestore.

mbraku avatar mbraku commented on August 16, 2024

Using getFirestore deosn't seem to be working for me. I'm always getting the "Firebase instance does not yet exist. Check your compose function." error (The error text should probably say "Firestore instance" though, right?)

When looking at the enhancer from react-redux-firebase I saw that you're assigning the return value of createFirebaseInstance first to firebaseInstance and then to store.firebase (see https://github.com/prescottprue/react-redux-firebase/blob/v2.0.0/src/enhancer.js#L96).

However, in the redux-firestore enhancer you're assigning the return value of createFirestoreInstance directly to store.firestore without assigning it to firestoreInstance first (see https://github.com/prescottprue/redux-firestore/blob/master/src/enhancer.js#L55).

My guess is that that's the issue I'm facing.

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

@mbraku That is totally correct, great catch! Will fix that now.

from redux-firestore.

dmcshehan avatar dmcshehan commented on August 16, 2024

Hello everyone,
I have noticed that we gan get a firestore instance like this with react-redux-firebase

export default function foo () {
  return function (dispatch, getState, { getFirebase}) {
    const firebase = getFirebase()
     const firestore = firebase.firestore();
     //do some stuff here
  }
}

Can't we use this method?

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

@dmcshehan that is the method works great if you are using a version which has a store enhancer (i.e. reduxFirestore) - the newer versions do not currently include that

from redux-firestore.

davidohlin avatar davidohlin commented on August 16, 2024

@dmcshehan that is the method works great if you are using a version which has a store enhancer (i.e. reduxFirestore) - the newer versions do not currently include that

@prescottprue how would I go about doing that in the new version? I'm trying to access getFirestore in an async action creator, but getting Error: Firebase instance does not yet exist. Check your compose function.

@karltaylor solution earlier in this issue also includes using reactReduxFirebase which, if I understand correctly, does not exist in ^3.0.0.

from redux-firestore.

prescottprue avatar prescottprue commented on August 16, 2024

@davidohlin Did you try getFirebase? You should be able to get getFirebase().firestore() though it isn't the enhanced methods that dispatch actions.

Going to look into the issue with getFirestore since there was also an issue in react-redux-firebase that mentioned it wasn't working as expected

from redux-firestore.

davidohlin avatar davidohlin commented on August 16, 2024

@prescottprue Yes, getFirebase().firestore() works, I'll use that for now. Thank you!

from redux-firestore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.