Search code examples
angularngrxngrx-store

Angular 15: NgRx store strictActionImmutability & strictStateImmutability errors


I am new to Angular and I got some errors due to the NgRx strictActionImmutability/strictStateImmutability checks, which are set to true by default.

I read some documentation, and to my understanding they verify the store's actions/states mutability.

Therefore, as suggested online, I edited my reducers by assigning the state cloned objects and also by dispatching clones to stores. Nevertheless, I still get errors ("cannot extend property X of object..") that disappear when I set the two checks to false.

I've also edited the selectors I made, in order to pass copied items, but I guess I'm missing something.

Could someone please list all the changes I need to implement to be compliant with the strictActionImmutability/strictStateImmutability?

Thanks a lot!


Solution

  • Update: I discovered some modifications left inside my reducers:

    on(TreeActions.UpdateActiveItem, (state, {item}) => ({ 
       \some operations/
        return {
          ...state,
          treeItem: [...newItem]
        }
      }))
    

    By removing the calculations and the return sintax everything works fine.