error defining specific class in state with factory function at the master branch #4622
-
Which @ngrx/* package(s) are the source of the bug?signals Minimal reproduction of the bug/regression with instructionsAt the commit e2f35c8 of signal store if a formgroup is defined as a state by factory function we have the following error. BehaviorSubject.js:34 Uncaught TypeError: Cannot assign to read only property '_value' of object '#<BehaviorSubject2>'
core.mjs:5907 Uncaught (in promise) TypeError: Cannot assign to read only property 'taskId' of object '#<_PendingTasksInternal>' It is reproducable as withState(() => {
return { formTest: new FormGroup({}) };
}), However this works withState({ formTest: new FormGroup({}) }), Expected behaviorWith 18.1.1 this is working. Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)Ngrx: e2f35c8 Other informationI guess upcoming withProps() would be a good practice to use forms in signal store but I post this in case it helps since there might be potential cases other than formgroups. I would be willing to submit a PR to fix this issue
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation. This was a trial to migrate existing project. I guess withProps will make a fit here? |
Beta Was this translation helpful? Give feedback.
The
FormGroup
instance or any other object with methods, observables, etc. should not be part of the SignalStore's state. The state should be a plain object instead.