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
Library Version:
aurelia-framework 1.3.1
aurelia-store 1.6.0
immer 6.0.3
Please tell us about your environment:
Operating System:
Windows 10
Node Version:
13.12.0
NPM Version:
6.14.4
JSPM OR Webpack AND Version
Webpack 4.42.1
Browser:
Firefox 75.0
Language:
TypeScript 3.8.3
Current behavior:
The Aurelia documentation guide for "Managing App State" demonstrates binding state properties directly in templates. The documentation then indicates that readers should review the Immer library to assist with ensuring their state remains immutable, implying that Immer is compatible with Aurelia when used in this way.
However, actually attempting to use Immer with Aurelia while binding directly to the store state results in the error "Immer drafts cannot have computed properties". I believe this is due to data-binding modifying the state objects with getters/setters for observing the values. The error means that Immer cannot reliably clone the object because it contains functions/getters/setters/computed properties.
Expected/desired behavior:
I spent a few hours researching and testing aurelia-store with Immer and aurelia-store, thinking I was doing something wrong. Eventually I gave up and asked about it in discord to find out it was a known issue.
IMO the documentation needs to be updated to remove mentioning Immer, or document an alternate approach that allows the use of Immer, such as not binding to the store state directly. Though I found even that can be tricky, as if you're not careful to properly copy your component state from the store state, aurelia still manages to bind into the store state and it's very difficult to track down where this is happening.
I also acknowledge I'm fairly new to Aurelia, so if I'm doing something wrong, please let me know.
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
aurelia-framework 1.3.1
aurelia-store 1.6.0
immer 6.0.3
Please tell us about your environment:
Operating System:
Windows 10
Node Version:
13.12.0
NPM Version:
6.14.4
JSPM OR Webpack AND Version
Webpack 4.42.1
Browser:
Firefox 75.0
Language:
TypeScript 3.8.3
Current behavior:
The Aurelia documentation guide for "Managing App State" demonstrates binding state properties directly in templates. The documentation then indicates that readers should review the Immer library to assist with ensuring their state remains immutable, implying that Immer is compatible with Aurelia when used in this way.
However, actually attempting to use Immer with Aurelia while binding directly to the store state results in the error "Immer drafts cannot have computed properties". I believe this is due to data-binding modifying the state objects with getters/setters for observing the values. The error means that Immer cannot reliably clone the object because it contains functions/getters/setters/computed properties.
More information about this error can be found here:
immerjs/immer#392
immerjs/immer#317
Possibly immerjs/immer#202
You can see this error in action here (Click the button after the app loads):
https://codesandbox.io/s/aurelia-javascript-sandbox-21zw1?file=/src/app.js
Expected/desired behavior:
I spent a few hours researching and testing aurelia-store with Immer and aurelia-store, thinking I was doing something wrong. Eventually I gave up and asked about it in discord to find out it was a known issue.
IMO the documentation needs to be updated to remove mentioning Immer, or document an alternate approach that allows the use of Immer, such as not binding to the store state directly. Though I found even that can be tricky, as if you're not careful to properly copy your component state from the store state, aurelia still manages to bind into the store state and it's very difficult to track down where this is happening.
I also acknowledge I'm fairly new to Aurelia, so if I'm doing something wrong, please let me know.
The text was updated successfully, but these errors were encountered: