From 68fef6d92470bab1f3137259d77eeaa52521ece7 Mon Sep 17 00:00:00 2001 From: Jeff Judkins Date: Sat, 28 Oct 2017 23:25:53 -0700 Subject: [PATCH] Call unset for Remove action instead of setWith MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setWith sets the value to undefined, but the key remains an enumerable property on the object. This can cause problems when your UI iterates over keys of an object and renders based on the key’s existence. Using unset, the key is removed. --- src/reducer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reducer.js b/src/reducer.js index bce574dd2..d857461bd 100644 --- a/src/reducer.js +++ b/src/reducer.js @@ -1,6 +1,6 @@ import { actionTypes } from './constants' import { pick, omit, get, isArray, isObject } from 'lodash' -import { setWith, assign } from 'lodash/fp' +import { setWith, assign, unset } from 'lodash/fp' const { START, @@ -185,7 +185,7 @@ const createDataReducer = (actionKey = 'data') => (state = {}, action) => { case NO_VALUE: return setWith(Object, getDotStrPath(action.path), null, state) case REMOVE: - return setWith(Object, getDotStrPath(action.path), undefined, state) + return unset(getDotStrPath(action.path), state) case LOGOUT: // support keeping data when logging out - #125 if (action.preserve) {