prescottprue / redux-firestore

Redux bindings for Firestore
MIT License
575 stars 102 forks source link

state not updated correctly after removing more than 1 item from sub collections (with batch function) #189

Open ofersarid opened 5 years ago

ofersarid commented 5 years ago

using the firestore batch function for deleting multiple items from a sub collection. "sometimes" the state just doesn't update correctly and instead of removing all deleted items it removes just 1. firestore database updates correctly. only after refreshing i get the correct state.

prescottprue commented 5 years ago

@ofersarid Please report what versions of dependencies you are using and how you are attaching listeners and/or rendering the data. All of this is necessary to try to reproduce.

ofersarid commented 5 years ago

from my packege.json

"react-redux-firebase": "^2.2.5",
"redux-firestore": "^0.7.2",

from my index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import thunk from 'redux-thunk';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import { reduxFirestore, getFirestore } from 'redux-firestore';
import firebase from '../firebase.config';
import { Router, hashHistory } from 'react-router';
import rootReducer from './cms/root-reducers';
import Routes from '/src/routes';

const store = createStore(
  rootReducer,
  composeEnhancers(
    applyMiddleware(
      thunk.withExtraArgument({ getFirebase, getFirestore }),
    ),
    reduxFirestore(firebase),
    reactReduxFirebase(firebase, {
      userProfile: 'users',
      useFirestoreForProfile: true,
      preserveOnDelete: true,
    }),
  )
);

ReactDOM.render(
  <Provider store={store} >
    <Router history={hashHistory} routes={Routes.routesMap} />
  </Provider >,
  $root
);

from my root-reducers.js

import { combineReducers } from 'redux-immutable';
import { firestoreReducer as fireStore } from 'redux-firestore';
import { firebaseReducer as firebase } from 'react-redux-firebase';

const rootReducer = combineReducers({
  fireStore,
  firebase,
});

export default rootReducer;

I believe this is all the relevant info, please let my know if you think anything else is necessary. did i articulate the problem well enough ? is it clear ?

it is reproducible simply by trying by using the batch function to remove items form a sub collection. happens almost every time. (sometimes the first try works)