Last Updated: December 23, 2016
·
922
· iondrimba

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 }));