React-redux-firebase: update multiple items using batch.commit() returns multiple responses

Created on 31 Jul 2019  路  5Comments  路  Source: prescottprue/react-redux-firebase

What is the current behavior?
We have a list of items. We do a batch update on some of the items using batch.commit();

We would expect a single response for the the batch update. However, we get individual responses for each item updated. This creates an issue in rendering the list. For example, if we do a batch update for 10 items, the list gets rendered 10 times.

We can observe this using Redux DevTools. Below line shows 10 times for a batch update of 10 items:

@@reduxFirestore/DOCUMENT_MODIFIED

Could you help me understand if there is a way to get a single response for each batch update?

What is the expected behavior?
We would expect a single response for the the batch update

Which version of redux-firestore are you using? What about other dependencies?
"redux-firestore": "^0.8.0"
"firebase": "^6.0.2",
"react-redux-firebase": "^2.3.0",

Which environments/browsers are affected by this issue? Did this work in previous versions or setups?
all browsers

Most helpful comment

All 5 comments

I think there is a similar issue at https://github.com/prescottprue/redux-firestore/issues/191 waiting to be fixed. This issue is related to redux-firestore directly so I think it will be a good idea to discuss there instead.

@illuminist thanks it solved my problem

Hello! Does anyone know how to do a batch writes with react-redux-firebase please?
For example lets say I have a collection A and B, I would like to update both of them but if one update fails I would like the other one to fail also.
Thank you :pray:

@SH-Stark The full firebase SDK is exposed by react-redux-firebase, so you should be able to do firebase.firestore().batch or firebase.firestore().runTransaction the same way described in the firestore docs

Was this page helpful?
0 / 5 - 0 ratings