diff --git a/lib/store/reducer.js b/lib/store/reducer.js index 3723c4f0..b2e451bf 100644 --- a/lib/store/reducer.js +++ b/lib/store/reducer.js @@ -154,7 +154,7 @@ function itemUpdated(state, id, { distance }) { if (!previous) return state; - const item = { + const next = { ...previous, value: { ...previous.value, @@ -162,11 +162,16 @@ function itemUpdated(state, id, { distance }) { }, }; + // right now the only item update possible is distance, + // if that hasn't changed, abort to prevent react rerendering + const distanceChanged = next.value.distance !== previous.value.distance; + if (!distanceChanged) return state; + return { ...state, items: { ...items, - [id]: item, + [id]: next, }, }; }