Can this be rewritten using Object.Assign or the spread operator?
This is an action creator for a redux call using closures. I believe this syntax can be improved.
const create = (actionName) => {
const type = `${actionName}`;
const func = ({ status, id = cuid() }) => ({
type,
payload: {
[id]: { status },
},
});
func.type = type;
return func;
};
Usage
const addQuestion = createQuestion("add");
const updateQuestion = createQuestion("update");