From 7f28ab895a73fe0677c62388b82e4d5f73e5c023 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 20 Apr 2020 17:56:22 -0700 Subject: [PATCH] Small change to creating an itemMap during item update --- frontend/src/Store/Actions/Creators/createHandleActions.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/Store/Actions/Creators/createHandleActions.js b/frontend/src/Store/Actions/Creators/createHandleActions.js index 36a103da1..afa0943ad 100644 --- a/frontend/src/Store/Actions/Creators/createHandleActions.js +++ b/frontend/src/Store/Actions/Creators/createHandleActions.js @@ -72,8 +72,12 @@ export default function createHandleActions(handlers, defaultState, section) { if (section === baseSection) { const newState = getSectionState(state, payloadSection); const items = newState.items; - const itemMap = newState.itemMap ?? {}; + // Client side collections that are created by adding items to an + // existing array may not have an itemMap, the array is probably empty, + // but on the offchance it's not create a new item map based on the + // items in the array. + const itemMap = newState.itemMap ?? createItemMap(items); const index = payload.id in itemMap ? itemMap[payload.id] : -1; newState.items = [...items];