You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, bindActionCreators accepts a single function or an object of functions. It would be useful if it accepted an array as well, to aid this code pattern:
import*asacfrom'./actionCreators';// later in file...const[doThis,doSomethingElse,doAnotherThing]=bindActionCreators([ac.doThis,ac.doSomethingElse,ac.doAnotherThing],dispatch);// ...
I like to specify my creator names explicitly because any mistakes are caught immediately by eslint-plugin-import/namespace as an error.
I believe this is the necessary change:
diff --git a/src/bindActionCreators.js b/src/bindActionCreators.js
index e70e270..6050c32 100644
--- a/src/bindActionCreators.js+++ b/src/bindActionCreators.js@@ -28,6 +28,10 @@ export default function bindActionCreators(actionCreators, dispatch) {
return bindActionCreator(actionCreators, dispatch)
}
+ if (Array.isArray(actionCreators)) {+ return actionCreators.map(ac => bindActionCreator(ac, dispatch));+ }+
if (typeof actionCreators !== 'object' || actionCreators === null) {
throw new Error(
`bindActionCreators expected an object or a function, instead received ${actionCreators === null ? 'null' : typeof actionCreators}. ` +
The text was updated successfully, but these errors were encountered:
Currently,
bindActionCreators
accepts a single function or an object of functions. It would be useful if it accepted an array as well, to aid this code pattern:I like to specify my creator names explicitly because any mistakes are caught immediately by eslint-plugin-import/namespace as an error.
I believe this is the necessary change:
The text was updated successfully, but these errors were encountered: