Skip to content
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

Javascript Set in state #95

Closed
Elaskin opened this issue Jul 24, 2023 · 5 comments
Closed

Javascript Set in state #95

Elaskin opened this issue Jul 24, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Elaskin
Copy link

Elaskin commented Jul 24, 2023

Describe the bug

  • if state includes javascript Set when state is reset, field becomes Object

Expected behavior

  • field resets to initial Set

error occures because of this line (utils.js:50)
image

@Elaskin Elaskin added the bug Something isn't working label Jul 24, 2023
huybuidac added a commit that referenced this issue Jul 25, 2023
@huybuidac
Copy link
Owner

@Elaskin I have fixed this, you can try on v1.2.2 for vue2 or v.4.1.0 for vue3

@Elaskin
Copy link
Author

Elaskin commented Jul 25, 2023

Thanks, is there a reason against structuredClone though?

@huybuidac
Copy link
Owner

Thanks, is there a reason against structuredClone though?

Yes, I used vuex util to clone https://github.com/vuejs/vuex/blob/main/src/util.js

It does not support Set, Map ... I have changed to other clone mechanism

@Elaskin
Copy link
Author

Elaskin commented Jul 26, 2023

Thanks, is there a reason against structuredClone though?

Yes, I used vuex util to clone https://github.com/vuejs/vuex/blob/main/src/util.js

It does not support Set, Map ... I have changed to other clone mechanism

I meant why not just use https://developer.mozilla.org/en-US/docs/Web/API/structuredClone

@huybuidac
Copy link
Owner

huybuidac commented Jul 26, 2023

I meant why not just use https://developer.mozilla.org/en-US/docs/Web/API/structuredClone

You can check it, the function requires recent versions of browser and node: https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility

Plain js is usually better approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants