Skip to content

Commit b25576d

Browse files
authored
Omit payload on undefined only (#128)
1 parent 1e818ab commit b25576d

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/__tests__/createAction-test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ describe('createAction()', () => {
9393
type
9494
});
9595

96-
const explictNullAction = createAction(type)(null);
97-
expect(explictNullAction).to.deep.equal({
98-
type
99-
});
100-
10196
const baz = '1';
10297
const actionCreator = createAction(type, null, () => ({ bar: baz }));
10398
expect(actionCreator()).to.deep.equal({

src/createAction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import identity from 'lodash/identity';
2+
import isUndefined from 'lodash/isUndefined';
23

34
export default function createAction(type, payloadCreator, metaCreator) {
45
const finalPayloadCreator = typeof payloadCreator === 'function'
@@ -13,7 +14,7 @@ export default function createAction(type, payloadCreator, metaCreator) {
1314
};
1415

1516
const payload = hasError ? args[0] : finalPayloadCreator(...args);
16-
if (!(payload === null || payload === undefined)) {
17+
if (!isUndefined(payload)) {
1718
action.payload = payload;
1819
}
1920

0 commit comments

Comments
 (0)