Skip to content

Commit

Permalink
Call unset for Remove action instead of setWith
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fej-snikduj committed Oct 29, 2017
1 parent 6a89f75 commit 68fef6d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 68fef6d

Please sign in to comment.