Redux action creator generator (ES6)
const createAction = (type, ...args) => {
let action = { type };
action = Object.assign({}, action, ...args);
return action;
};
export default createAction;
Usage
dispatch(createAction('actionName', { data1, data1 }));
For simple values
dispatch(createAction('actionName', { text:'Hello' }));
dispatch(createAction('actionName', { value:false }));
Written by Ion D. Filho
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Js
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#