Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor enhancement to allow empty argument to actionCreator with defaults #98

Closed
snmishra opened this issue Jan 27, 2020 · 3 comments · Fixed by #102
Closed

minor enhancement to allow empty argument to actionCreator with defaults #98

snmishra opened this issue Jan 27, 2020 · 3 comments · Fixed by #102
Assignees

Comments

@snmishra
Copy link

Currently the actionCreator with defaults accepts only an object (see #35). A default argument of empty object will be nice, so you can call the action creator without an argument.

diff --git a/lib/createActions.js b/lib/createActions.js
index 67cdb84..68dc029 100644
--- a/node_modules/reduxsauce/lib/createActions.js
+++ b/node_modules/reduxsauce/lib/createActions.js
@@ -51,7 +51,7 @@ const createActionCreator = (name, extraPropNames, options) => {
   // "properties" is defined as an object of {prop name: default value}
   if (is(Object, extraPropNames)) {
     const defaultProps = extraPropNames
-    return (valueObject) => {
+    return (valueObject = {}) => {
       const providedProps = pick(Object.keys(defaultProps), valueObject)
       return { type, ...defaultProps, ...providedProps }
     }
@jkeam
Copy link
Owner

jkeam commented Mar 6, 2020

Ah. Ya I can definitely look into this, but since you did all the hard work, do you want to open a PR (and add tests)? :)

@ghost
Copy link

ghost commented Mar 6, 2020

It was just adding a default option, thought it would be easier as a patch. In any case I’ve moved on from the project. So I won’t have time in the near future to do a PR or tests.

Edit: sorry, replied from my corporate account

@jkeam jkeam linked a pull request Apr 5, 2020 that will close this issue
@jkeam jkeam self-assigned this Apr 5, 2020
@jkeam
Copy link
Owner

jkeam commented Apr 5, 2020

Thanks again for your contribution! I created #102 to address this. This has been merged in and will be in the next release.

@jkeam jkeam closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants