So, Object.assign() copies the properties of the objects passed to them on the target object. So what you need to pass are objects with properties that it can copy.
If you are trying to create an object that has a property based on the current execution of the switch statement (this is my hunch about what you are trying to do), then I suggest you just create the source object before calling Object.assign() and pass that object to it.
By doing this, as I will show here, you will avoid any side effects that could change the one passed in the object too (why do we set the properties in the switch statement on the local object, and not on the state object):
const agendaPointsReducer = function (state = initialState, action) { let srcObj = {}; switch (action.type) { case OPEN_AGENDA_POINT: srcObj.modal_is_open = true; srcObj.point_id = action.id; break; case CLOSE_AGENDA_POINT: srcObj.modal_is_open = false; break; } return Object.assign({}, state, srcObj); }
source share