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

slots not re-rendering while passing $scopedSlots to children #13066

Open
woshiguabi opened this issue Aug 17, 2023 · 1 comment
Open

slots not re-rendering while passing $scopedSlots to children #13066

woshiguabi opened this issue Aug 17, 2023 · 1 comment

Comments

@woshiguabi
Copy link

Version

2.7.14

Reproduction link

codesandbox.io

Steps to reproduce

Click the change button

What is expected?

slot re-rendering

What is actually happening?

slot not re-rendering


To reproduce this issue, two conditions must be met

  1. Both slot and scopedSlot are passed to the parent component
  2. The parent component passes $scopedSlots to the child component

After deconstructing $scopedSlots this issue resolved, but this issue is important for library developers because passing $scopedSlots is a very common usage.

@yunchuan123
Copy link

yunchuan123 commented Dec 21, 2023

I think it might be because you directly passed this.$scopedSlots into Inner.data.scopedSlots, which led to the implicit property $stable that was originally defined in Wrapper.$scopedSlots also being transferred to Inner.data.scopedSlots.
So this is why using the spread operator works fine, because the spread operator does not expand implicit properties.

excepted

image.

actually(in your example)

image

And then, due to Vue's slot optimization mechanism, it ultimately led to the following logic...
image
So, Vue reused the previous scoped slot object, thereby reducing the rendering overhead.

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