diff --git a/src/__tests__/createAction-test.js b/src/__tests__/createAction-test.js index 1265dd9a..ca4787af 100644 --- a/src/__tests__/createAction-test.js +++ b/src/__tests__/createAction-test.js @@ -95,11 +95,12 @@ describe('createAction()', () => { const explictNullAction = createAction(type)(null); expect(explictNullAction).to.deep.equal({ - type + type, + payload: null }); const baz = '1'; - const actionCreator = createAction(type, null, () => ({ bar: baz })); + const actionCreator = createAction(type, undefined, () => ({ bar: baz })); expect(actionCreator()).to.deep.equal({ type, meta: { diff --git a/src/createAction.js b/src/createAction.js index 89fa274a..7b34f4b2 100644 --- a/src/createAction.js +++ b/src/createAction.js @@ -1,4 +1,5 @@ import identity from 'lodash/identity'; +import isUndefined from 'lodash/isUndefined'; export default function createAction(type, payloadCreator, metaCreator) { const finalPayloadCreator = typeof payloadCreator === 'function' @@ -13,7 +14,7 @@ export default function createAction(type, payloadCreator, metaCreator) { }; const payload = hasError ? args[0] : finalPayloadCreator(...args); - if (!(payload === null || payload === undefined)) { + if (!isUndefined(payload)) { action.payload = payload; }