After upgrading Angular 4 to 10 and NGRX version (to v 9) I am getting multiple errors while trying to do any operation.
My application is breaking every time I am making a http call.
I am getting below errors and sometimes there is no errors/warnings but the page is breaking.
The issue is not related to Angular, it is NGRX version upgrade issue
store objects are readonly so any update to store data in action,reducer,effect and selector will throw a similar err you have mentioned
to fix this:
For creating a new reference you can use
... operator(tricky one for nested objects)
JSON.parse(JSON.stringfy(data))(not full proof for nested objects and all type)
Object.assign({}, obj);
cloneDeep (if you are using lodash) or write custom method to deep clone object
Also you may get few syntax errors , Please use the link
https://ngrx.io/guide/migration and read the guide for the version you are migrating from
https://ngrx.io/guide/migration/v8
workaround : In the previous version of NgRx, runtime Immutability checks were opt-in. In version 9 and higher , the immutability runtime check is turned on by default.
so you can set it to false :
@NgModule({
imports: [
StoreModule.forRoot(reducers, {
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false,
},
}),
],
})
export class AppModule {}
your code will work as earlier but this is not the correct solution.
use this link for more information