redux-firestore
redux-firestore copied to clipboard
bug(orderedReducer): updating a document on Firestore creates a duplicate on the state
When updating a document on Firestore, the document is update as intended on the state in real time. But if you change back the property to its initial value, a duplicate is generated on the state. This is happening on the 0.10.0 version.
I'm using it with react-redux-firebase, and had this issue. Rolling back to the previous version (0.9.0) fixed it.
I hit a similar snag on state.firestore.ordered
so instead of rolling back to 0.9.0, I used the state.firestore.data
property, which wasn't getting the duplicate record added.
Could you share the listener settings that caused this to happen for you or a full repro example? Having trouble replicating the described issue.
As @Beamanator mentioned, it should work to use data
state instead, and that is actually a good move since in the future the plan is to have ordered
become just keys as described in #204.
I faced with the same issue (in v0.13.0
).
In my case, I update a doc's field which specified order by
to change order, the updated doc has not id
key and duplicate the document.
So I tried changing orderedReducer.newArrayWithItemMoved
passing arguments to add doc id, it works.
before
https://github.com/prescottprue/redux-firestore/blob/b5d5f312a078cb41f3d297863bd67df332a5e265/src/reducers/orderedReducer.js#L63
after
{
id: action.meta.doc, // Add doc id
...action.payload.data
}
I don't know the details, but I thought it might related with this issue. Perhaps, the id key is needed to find on updating so orderReducer duplicates the updated oredered data?
If you still need some example repo, I can create it.
Experience this same issue. When modifying docs, there is duplication of objects in the ordered array. This duplication does not occur in the data object.