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

Pushing to v-for loop list updates more components than expected #11402

Closed
Skasi opened this issue May 19, 2020 · 1 comment
Closed

Pushing to v-for loop list updates more components than expected #11402

Skasi opened this issue May 19, 2020 · 1 comment

Comments

@Skasi
Copy link

Skasi commented May 19, 2020

Version

2.6.11

Reproduction link

https://codesandbox.io/s/component-update-test-66fjt?expanddevtools=1&module=%2FApp.vue

Steps to reproduce

Either check out the reproduction link above, OR follow these steps:

  1. Make a list (array or object, doesn't matter): data() { return { list: [] } }
  2. Use a v-for-loop to go through list and for each entry, render a component<Test :key="i"></Test>
  3. Add any text/element/etc. inside the element: <Test:key="i">any string</Test>
  4. Push a new entry to the list: this.list.push(....)

What is expected?

A new component is created and added to the list, other components inside the list remain "untouched".

What is actually happening?

A new component is created and added to the list and each already-existing instance of <Test> rendered in the list has their updated hook called.


Removing the text will stop updated-hooks from being called. Passing the same text as a prop and rendering it inside the component will not call updated-hooks.

Adding a <slot> to the template of the child component has no impact on updated-hook calls.

I'm not sure whether this is another version of #6351 or not. That issue is about updating slot content, whereas the issue here is about rendering multiple components via v-for while slot content remains the same.

@posva
Copy link
Member

posva commented May 19, 2020

As you noticed it is the same as #6351. When adding new entries to the array, the slot renders again and needs to be passed to Test and render it again in case it changed

@posva posva closed this as completed May 19, 2020
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