I\'m using @ngrx/store for an Angular 2 app.
My store holds a list of say, Book
objects. I want to update a field in one of those objects. I also happ
I'll have to make an assumption about the actual scenario the OP is experiencing.
The problem
It's not possible to modify a member of a frozen object. Its the error being thrown.
The cause
ngrx-store-freeze
is used as a meta-reducer to freeze any object that enters the store. On another place, when an object needs to be changed, a shallow copy is being made. Object.assign()
doesn't do deep copy. A member of another object reached from the original object is being modified. This secondary object is also frozen, by it is not duplicated.
Solution
Use a deep copy like cloneDeep()
from lodash. Or sent a bag of properties to be changed with a proper action. Process the changes on the reducer.