Subscribe on changes!

If the reactively object is regenerated into a new proxy object, the newly generated proxy object is no longer reactive

avatar
Mar 24th 2022

Version

3.2.31

Reproduction link

github.com

Steps to reproduce

const obj = reactive({name: 'Hello'});
const newProxyObj = new Proxy(obj, {});

effect(()=>{
  console.log('reactively: '+obj.name);
})

obj.name = 'test1' // > reactively: test1
newProxyObj.name = 'test2' // nothing to print

// but value is changed
console.log(obj.name) // > test2

What is expected?

Making proxy can works well

What is actually happening?

I want to using proxy to limit some updates in reactive object

avatar
Mar 24th 2022

You need to properly chain the Proxy get calls with Reflect.get so that the value is read directly from the reactive object and Vue can track the read/write