I'm getting this error:
Cannot assign to read only property 'active' of object '[object Object]'
I know that the message means, I can't work on the state directly. Overall i'm trying to switch a boolean. my reducer is
on(ConfigsActions.toggle, (state, data) => {
const clone = getAllConfigs.projector();
const conf = clone.find(f => f.id === data.config.id);
conf.domains.forEach(domain => {
domain.features.forEach(feature => {
if(feature.settingId === data.setting.settingId) {
feature.active = !feature.active;
}
else {
feature.components.forEach(component => {
if(component.settingId === data.setting.settingId) {
component.active = !component.active;
}
})
}
})
}
);
return configsAdapter.updateOne({id: conf.id, changes: {
domains: conf.domains
}}, state);
})
What am I doing wrong? Maybe the reducer is not where I should make those changes?