I've been using angular-redux on my current project at work for quite a while, recently I noticed very strange behavior and it seemed to me that State is being mutated! Then I've installed redux-freeze and got a lot of object is not extensible
errors.
Right now the problematic flow looks like this:
I have a container that has
@select(selector_name) data: Observable<Data>
to get a slice of data, then I pass the data to a child component like this
<child-component [data]="data | async"...
In the child component I can change some fields of the data
object and emit the object back to the container, and then container sends the data to the server.
// child component
@Input() data: Data;
@Output() dataChanged = new EventEmitter<Data>();
someFunction(newFieldData: string) {
this.data['field'] = newFieldData; // at this point 'object is not extensible' error is thrown
this.dataChanged.emit(this.data);
}
What is the right way of doing basically the same but also prevent object is not extensible
error from happening?