I have an action 'set-style' sent to a reducer where i change a style object of a specified-by-key object in an array of objects, named layers.
The difficulty is - 'filterName' is used to receive the property name needed to be changed. If i use another property name it does behaves correct, but the 'filterName' variable does not function as a key.
export const set_stl = (val,filterName,chosenLayerId,chosenLayerIdx=0,layers) => {
const specLayer = layers[chosenLayerIdx];
const assignedSpecLayer = Object.assign({}, specLayer, {
stl: {
...specLayer.stl,
filterName: val
}
});
const newLayers = layers;
newLayers[chosenLayerIdx] = assignedSpecLayer;
return dispatch => {
dispatch({
type: SET_STL,
payload: newLayers,
})
}
};