Comments (12)
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.
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.
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.
There are two options:
- use
store.firestore from your redux store by passing
this.context.store.firestorein the
payloadof the action you
dispatchto call your saga (make sure you provide
contextTypes`) - 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.
v0.1.0-beta
was released with getFirestore
in there. Let me know if it does not work as expected.
from redux-firestore.
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.
@mbraku That is totally correct, great catch! Will fix that now.
from redux-firestore.
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.
@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.
@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.
@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.
@prescottprue Yes, getFirebase().firestore()
works, I'll use that for now. Thank you!
from redux-firestore.
Related Issues (20)
- storeAs inconsistency
- How to read a deeply nested document?
- Got undenfined firestore state on my next.js app HOT 1
- Typescript: firestore: FirestoreReducer.Reducer; No overload matches this call.
- Support Firebase 8 HOT 12
- Can't update subcollection object HOT 1
- how to populate an array
- When should i not use redux-firestore HOT 4
- Immediate mode: instant, synchronous document updates HOT 6
- Firestore Reducer Type Documentation HOT 3
- Cannot find Reducer in index.d.ts
- Collectiongroup delete not updated
- endBefore not working as expected HOT 3
- ordered reducer duplicated items
- dispatch({ type: actionTypes.CLEAR_DATA }) does not clear 'queries' and 'composite' HOT 2
- Dependency Dashboard
- @firebase/firestore: Firestore (8.2.1): Connection WebChannel transport errored
- StartAfter does not take into consideration documents with similar values (Skips some documents) HOT 1
- The automated release is failing 🚨
- Path,Id is appended on all docs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-firestore.