Code snippet:
updateSelectedAreaColor: (state, payload) => {
state.selectedArea = { ...state.selectedArea, color: payload };
},
I'm updating the property color of the object state.selectedArea with a payload. Instead of hard-coding the property to be updated, I would like to set the property through my payload.
For example:
updateSelectedAreaColor: (state, payload) => {
state.selectedArea = { ...state.selectedArea, payload.target: payload.value };
},
However, this code throws an error. Does anyone know how I can set the value to be updated via the payload?