-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
triggerRef not update for shallowRef when watching multiple values (Array argument) #5371
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
Comments
as workaround: watch(...[arr], ()=> {
console.log('watch [arr] : arr change, but not trigger watch')
}) |
Edit: I'm rather confused why the first one does work at all. It's a shallow ref. Edit2: Nevermind I missed the whole point |
triggerRef for shallowRef |
its a bug. core/packages/runtime-core/src/apiWatch.ts Lines 213 to 219 in 9c304bf
this might be a possible patch forceTrigger = source.some(isReactive)||source.some(isShallow) |
@LinusBorg hi! can i ask a question about watch implementation? why do we treat ref and shallow ref differently, when we use shallow ref, the callback function is forced to fire.I don't seem to see the corresponding instructions on the official documentation. core/packages/runtime-core/src/apiWatch.ts Lines 204 to 215 in 5898629
core/packages/runtime-core/src/apiWatch.ts Lines 307 to 311 in 5898629
|
@kuang-lingxi see #2231 |
thanks reply!actually I saw this issue yesterday via git commit. In the previous implementation, the check was skipped by judging whether it was a ref. actually I don't really understand why ref skips the check. or i change the question, what is the expected behavior of the watch function when it accepts ref/shallow ref/reactive object? Is there any documentation on this? |
Version
3.2.30
Reproduction link
sfc.vuejs.org/
Steps to reproduce
1、watch shallowRef by arr
2、triggerRef
What is expected?
trigger watch
What is actually happening?
not trigger watch
The text was updated successfully, but these errors were encountered: