vuejs / vuejs/core

Callbacks for watching multiple props sources differ from wrapped callbacks in components

Open
#8,481 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

has workaround need discussion
Dominant language
TypeScript
Stars
54.4k
Forks
9.2k
Avg merge
1d 5h
Merged PRs (30d)
140

Description

Vue version

^3.2.47

Link to minimal reproduction

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

Steps to reproduce

Go to reproduction.
And make code like this.

// in App.vue
-  <CompB :foo="model.foo" :bar="model.bar" />
+ <CompWrapper>
+   <CompB :foo="model.foo" :bar="model.bar" />
+  </CompWrapper>

And change input value

What is expected?

Change input value once to callback console.log('CompB props changed') twice in CompB.vue.
It should not behave differently when make code like this.

// in App.vue
+  <CompB :foo="model.foo" :bar="model.bar" />
- <CompWrapper>
-   <CompB :foo="model.foo" :bar="model.bar" />
-  </CompWrapper>
What is actually happening?

Change input value once to callback console.log('CompB props changed') once in CompB.vue.
In other words,the number of watch callbacks is consistent with the watch([() => model.foo, () => model.bar] in App.vue

System Info

No response

Any additional comments?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and compare the direct and wrapped cases in App.vue, CompB.vue, and CompWrapper. Trace how the multiple-props watch callback behaves in each case, then verify that changing the input produces the same callback count in both arrangements.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.