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

When switching between two of the same components with slot using v-else, I get a render error #9534

Comments

@cypressious
Copy link

Version

2.6.6

Reproduction link

https://codesandbox.io/s/4l3wn6r3nx

Steps to reproduce

Check the checkbox to trigger the error

What is expected?

The value "2" should be rendered

What is actually happening?

[Vue warn]: Error in render: "TypeError: item.a is undefined"

found in

---> <HelloWorld> at /src/components/HelloWorld.vue
       <App> at /src/App.vue
         <Root>

and "1" is still being rendered.


I have two of the same components next to each other and switch between them using v-else.

This used to work in earlier versions of Vue but in 2.6.6 I get this unexpected render error. It appears as if component 1 is being rendered with the properties of component 2.

@LinusBorg
Copy link
Member

LinusBorg commented Feb 20, 2019

Since you didn't key the two component instances, the same instance will be re-used, and that's fine in itself.

But it seems that the optimizations for (scoped) slots that we introduced in 2.6 have an unwanted side-effect here, namely that also the scoped slot is re-used / cached when the instance is "switched".

A workaround would be to add a key to at least one of the two component instances.

Lostlover pushed a commit to Lostlover/vue that referenced this issue Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment