When customizing hooks, the issue of not taking effect when the params is reactive data
Vue version
3.2.47
Link to minimal reproduction
Steps to reproduce
{{ newValue }}What is expected?
I expect my params to be also reactive
What is actually happening?
After reassigning state.obj, I used isReactive to see if the object was still a reactive object, but the watch function was not triggered
System Info
System: OS: Windows 10 10.0.19044 CPU: (4) x64 Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz Memory: 3.91 GB / 11.89 GB Binaries: Node: 16.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Chromium (113.0.1774.57) Internet Explorer: 11.0.19041.1566 npmPackages: vue: ~3.2.31 => 3.2.31
Any additional comments?
No response
@1020847665 You are watching on state.obj
and then assigning it a new value to it. In that case that watcher will not get triggered.
const obj = reactive({
child: {
key: 'value'
}
})
watch(obj, (val) => console.log('watch obj', val), { deep: true }) // triggered
watch(obj.child, (val) => console.log('watch obj.child', val), { deep: true }) // not triggered
obj.child = 'updated'
This is not a bug!