Fix CRUDReducer bug when retrieving item that already exists

This commit is contained in:
Jerko Steiner 2019-04-03 23:51:38 +08:00
parent a81a68b6e2
commit 363b84699f

View File

@ -115,10 +115,14 @@ export class CRUDReducer<
}
handleFindOne = (state: ICRUDState<T>, payload: T): ICRUDState<T> => {
const ids = !state.byId[payload.id]
? [...state.ids, payload.id]
: state.ids
return {
...state,
ids: [...state.ids, payload.id],
ids,
byId: {
...state.byId,
[payload.id]: payload,
},
status: {