Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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: 3 additions & 2 deletions src/__tests__/createAction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/createAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function createAction(type, payloadCreator, metaCreator) {
};

const payload = hasError ? args[0] : finalPayloadCreator(...args);
if (!(payload === null || payload === undefined)) {
if (payload !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use the lodash function lodash/isUndefined here?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, but just consider that it does exactly the same thing: https://github.com/lodash/lodash/blob/master/lodash.js#L11878

action.payload = payload;
}

Expand Down