docs icon indicating copy to clipboard operation
docs copied to clipboard

`structuredClone` api will produce an error if argument is reactive object

Open mrleblanc101 opened this issue 8 months ago • 1 comments

I've recently stumbled upon this issue https://github.com/vuejs/core/issues/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 avatar Apr 16 '25 14:04 mrleblanc101

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

mrleblanc101 avatar Apr 16 '25 14:04 mrleblanc101