Executing multiple queries does not save results of the previous query
See original GitHub issueWhat is the current behavior? Executing multiple queries in the same firestoreConnect only preserves the result of the last one. Workaround is to use storeAs but there is a sideeffect. With storeAs, the results from populates are only saved for the very last query.
I could see in console the queries and populates are executed as expected but the result from the previous query becomes undefined when the result of the next query appears in the console.
Note that the commonality between my experience and #227 is that our queries were executed on the same collection.
What is the expected behavior?
- ideally, results of the query is preserved without storeAs
- results of populates is saved for all queries
Which version of redux-firestore are you using? What about other dependencies? 0.8.0 dependencies: immer “1.5.0” lodash “^4.17.11” reduce-reducers “0.4.3”
Which environments/browsers are affected by this issue? Did this work in previous versions or setups? reactjs web, react native in chrome and iphonex #227 mentions that popultes did work in 0.7.0
Minimal demo to reproduce issue (using codesandbox or similar)
const populates = [{ child: 'activityID', root: 'activities', keyProp: 'key'}]
const mapStateToProps = state => {
return {
activities: state.firestore.ordered.act,
currentActivities: populate(state.firestore, 'currentActivities', populates),
completedActivities: populate(state.firestore, 'completedActivities', populates)
}
}
export default compose(
firestoreConnect(() => [
{
collection: 'activities',
storeAs: 'act'
},
{
collection: 'users',
doc: 'IF6HzQjcxjXmlwnDk5wBSYXnXh73',
subcollections: [{ collection: 'completedActivities' }],
populates: populates,
storeAs: 'completedActivities'
},
{
collection: 'users',
doc: 'IF6HzQjcxjXmlwnDk5wBSYXnXh73',
subcollections: [{ collection: 'currentActivities' }],
populates: populates,
storeAs: 'currentActivities'
},
]),
connect(mapStateToProps)
)(ActScreen)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
It does have a “principled way” - and there are even
isLoaded
andisEmpty
helpers to assist in checking for those state as described in the queries section of the react-redux-firebase docs.Definitely. I think it’s fast becoming my go to lib for web/mobile dev now. It really simplifies the need for an ORM, writing your own redux-specific code, and the population capability is just genius 💯 The fact that I have the option of dropping in rn-firebase just makes forward planning so much easier
I’m learning now if the rrf has a principled way of deciding when to return data using store or when to query the database, though I suppose this might be out of scope for the lib. Any tips on how/where I could write code to make this decision would be great. Joining gitter now!