Skip to content

structuredClone api will produce an error if argument is reactive object #3223

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

Open
mrleblanc101 opened this issue Apr 16, 2025 · 1 comment

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Apr 16, 2025

I've recently stumbled upon this issue vuejs/core#8975.
I think the documentation should include tips on how to clone a ref/reactive.

Since ref and reactive allow to compose reactive objects, toRaw still may not work for them due to how it works: https://stackoverflow.com/a/72633173/16716350

Maybe the doc should recommend an official cloning library ?
useCloned from VueUse or klona ?

@mrleblanc101 mrleblanc101 changed the title structuredClone api will produce an error if argument is reactive object structuredClone api will produce an error if argument is reactive object Apr 16, 2025
@mrleblanc101
Copy link
Author

mrleblanc101 commented Apr 16, 2025

Or maybe Vue should add a utility ?
Since Vue already ship multiple other utility https://vuejs.org/api/reactivity-utilities.html, maybe we could have something like toClone() or toCloned.
This new utility would handle ref/reactive that are composed with other ref/reactive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant