-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: TypeError: 'ownKeys' on proxy: trap result did not include 'scope' #162
Comments
You need disabled development mode |
However, this is a bug and I need to reproduce it. |
Here is my project when you can reproduce |
@xmlking well I was able to reproduce the error |
Sorry |
done (v3.0.1) |
No problem. appreciate your work and quick release 👍 |
Again ERROR TypeError: 'ownKeys' on proxy: trap result did not include 'scope' |
@victos create issue with reproduce |
This error occurred when I get the property from getState and put it back within setState. Maybe this is not a bug. The property get from the getState is not a pure JavaScript object. |
I will not be able to help unless I see specific examples. |
Here's an example, https://stackblitz.com/edit/angular-jwqaif3?file=src/app/app.module.ts |
Sorry to emphase but It's a catastrophic bug. |
Maybe you can use the function isDraft to know if an object is a Proxy, and use function original to get the pure JavaScript object from the Proxy |
Thank. I learned I need to learn more about Proxy :) Anyway I finally found a workaround, before reading you comment. @Action(OpenCategory)
@ImmutableContext()
openCategory({setState, getState}: StateContext<CatalogState>, {categoryToOpen}: OpenCategory) {
let state: CatalogState = cloneDeep(getState());
state.current.page = 0;
state.current.product = null;
// until now, we are cool.`setState` would work:
// setState(s => state);
// But now this line would error my setState:
// state.current.category = categoryToOpen;
// `categoryToOpen` is indeed a proxy
// So I simply had to make a clone to make is work (cloneDeep is just a JSON parse /stringify)
state.current.category = cloneDeep(categoryToOpen);
// Edit: just tested and indeed, using original work like charm
state.current.category = original(categoryToOpen);
//working
setState(s => state);
} Any comment on the above code is more than welcome |
@dfa1234 Only use it if you have a simple object with only values. |
after switching to
@ngxs-labs/immer-adapter": "^2.0.1"
, i am getting following errorThe text was updated successfully, but these errors were encountered: