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

deepmerge with arrayMerge option adds proxy to nested array #12776

Open
youri-spendcloud opened this issue Jan 24, 2025 · 2 comments
Open

deepmerge with arrayMerge option adds proxy to nested array #12776

youri-spendcloud opened this issue Jan 24, 2025 · 2 comments

Comments

@youri-spendcloud
Copy link

youri-spendcloud commented Jan 24, 2025

Vue version

^3.5.13

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-4umr7oj9?file=src%2FApp.vue

Steps to reproduce

Run the stackblitz and open the console.

What is expected?

These weird proxied arrays should not be created?

What is actually happening?

With the arrayMerge option, the nested arrays are merged with proxies. Now for example a localForage can't clone the object.

Without the option, both the reactive objects are merged and they have no nested arrays with proxy.

Image

System Info

Any additional comments?

Related issue on vuex-persist

championswimmer/vuex-persist#271 (mine)

Other users reporting the same "cannot clone error" when migrating from Vue 2 to Vue 3.

championswimmer/vuex-persist#232
championswimmer/vuex-persist#235

@jamesnakagawa
Copy link

  • Perhaps try shallowReactive if you don't want deeply-nested Vue proxies
  • If that doesn't work for you, try Vue's toRaw in your array merge handler:
const overwriteMerge = (destinationArray, sourceArray, options) =>
  toRaw(sourceArray);

@youri-spendcloud
Copy link
Author

@jamesnakagawa that would be a solution, but my question is how is is possible, that the deepmerge creates a proxy on the nested arrays

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

2 participants