Skip to content

Component with slot rerenders even if the slot or component data has not changed #6898

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

Closed
jacekkarczmarczyk opened this issue Oct 24, 2017 · 7 comments

Comments

@jacekkarczmarczyk
Copy link

Version

2.5.2

Reproduction link

https://codepen.io/anon/pen/NaVVpW?editors=1011

Steps to reproduce

Type something in the input

What is expected?

render method of the Test component shouldn't be called

What is actually happening?

render method of the Test component is called


It is an serious performance issue if the component is complicated, it's rerendered even if nothing changes

@jacekkarczmarczyk jacekkarczmarczyk changed the title Component with slot rerenders even if the slot has not changed Component with slot rerenders even if the slot or component data has not changed Oct 24, 2017
@LinusBorg
Copy link
Member

LinusBorg commented Oct 24, 2017

Well, it has to re-render to see if anything changed, or not. I understand that you may think "we could simply diff the new vnodes in the parent, and not pass them to the child when there's no diff"

Unfortunately that doesn't take into account all possible edge cases, so there's no easy way around that in the current architecture.

Also, assuming we could go this route, this would have a performance trade-off: As we would still have to diff the vnodes in the child, we diff the same vnodes two times now - which means that for components that are light themselves and receive large slot contents, the performance would worsen.

And I think that large slot trees are pretty common, as they are even nested quite often.

Concerning your situation: If you are encountering performance issues, there are other options to optimize, most useful here are probably:

  • extracting the heavy part into another child component which doesn't receive the slot,
  • using v-once if you have large node trees that only need to render once during the component's lifecycle.

@LinusBorg
Copy link
Member

Hm, so I just took a look at the issues you mentioned this one in. Indeed sub-optimal.

@yyx990803 Can you share some insight?

@yyx990803
Copy link
Member

There is already plan to improve and is tracked in #6351

@jacekkarczmarczyk
Copy link
Author

Thank you!

@LinusBorg
Copy link
Member

Wow, that's a weird feeling seeing my own answer in #6351 and seeing how it's almost verbatim the same I gave here, but I have no recollection of that other reply :D

Glad that this will be improved though.

@KaelWD
Copy link
Contributor

KaelWD commented Nov 15, 2017

Turns out john came across the same thing a few months ago: #5155

@Phlow2001
Copy link

I haven't looked deeply at the whole update/render pipeline, so speaking conceptually, I'm curious why dependency changes alone can't determine if a component/slot should re-render?

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

5 participants