Fix CRUDReducer bug when retrieving item that already exists
This commit is contained in:
parent
a81a68b6e2
commit
363b84699f
@ -115,10 +115,14 @@ export class CRUDReducer<
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleFindOne = (state: ICRUDState<T>, payload: T): ICRUDState<T> => {
|
handleFindOne = (state: ICRUDState<T>, payload: T): ICRUDState<T> => {
|
||||||
|
const ids = !state.byId[payload.id]
|
||||||
|
? [...state.ids, payload.id]
|
||||||
|
: state.ids
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
ids: [...state.ids, payload.id],
|
ids,
|
||||||
byId: {
|
byId: {
|
||||||
|
...state.byId,
|
||||||
[payload.id]: payload,
|
[payload.id]: payload,
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user