You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When initializing a store and defining the initial state in the constructor, that initial store is not produced by immer and thus not immutable until a state change has been performed.
interfaceTestState{test: string;}
@Injectable({providedIn: 'root'})exportclassTestStoreextendsImmerComponentStore<TestState>{constructor(){super({test: 'foo'});this.get().test='bar';// should throw an error but does not}}
Replacing the defaultState in the super call by a produced value correctly causes an error to be thrown.
super(produce({ test: 'foo' }, x => x));
The text was updated successfully, but these errors were encountered:
SebastianPost1996
changed the title
defaultState (via constructor) is not immutable
ImmerComponentStore: defaultState (via constructor) is not immutable
May 15, 2024
When initializing a store and defining the initial state in the constructor, that initial store is not produced by immer and thus not immutable until a state change has been performed.
Replacing the defaultState in the
super
call by a produced value correctly causes an error to be thrown.The text was updated successfully, but these errors were encountered: