Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/__tests__/createAction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ describe('createAction()', () => {
type
});

const explictNullAction = createAction(type)(null);
expect(explictNullAction).to.deep.equal({
type
});

const baz = '1';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of this test? It doesn't have anything to do with the test name and is already being tested here.

const actionCreator = createAction(type, null, () => ({ bar: baz }));
expect(actionCreator()).to.deep.equal({
Expand Down
3 changes: 2 additions & 1 deletion src/createAction.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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;
}

Expand Down