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

Props can get out of sync on dynamic components with keep-alive #4237

Closed
sebpettersson opened this issue Nov 17, 2016 · 3 comments
Closed

Props can get out of sync on dynamic components with keep-alive #4237

sebpettersson opened this issue Nov 17, 2016 · 3 comments
Labels

Comments

@sebpettersson
Copy link

I'm not sure if this is a bug or intended behavior, but if so, maybe this could be clarified in the documentation (and how to go about getting fresh values passed down after coming back from an inactive state).

Vue.js version

2.0.7

Reproduction Link

https://jsfiddle.net/ueLxbc0f/3/

Steps to reproduce

  1. Click on Switch component
  2. Click Increase value
  3. Click on Switch component

What is Expected?

That the component has its prop updated when coming back from inactive state.

What is actually happening?

The prop of the component is out of sync with its parent's data.

@defcc
Copy link
Member

defcc commented Nov 18, 2016

If you want to keep the switched-out components in memory so that you can preserve their state or avoid re-rendering, you can wrap a dynamic component in a element:

According to the docs, it should be an expected behavior, that's what keep-alive does.

@defcc defcc added the 2.0 label Nov 18, 2016
@sebpettersson
Copy link
Author

sebpettersson commented Nov 18, 2016

I understand that the state is preserved (like all data in the component), but to me it feels a bit unintuitive that in addition to that, dynamically bound props breaks under these circumstances.

Edit: If this is the expected behavior, shouldn't there at least be away to force dynamically bound props to update themselves when a kept-alive component appears?

@simplesmiler
Copy link
Member

It looks like a bug to me. I'd expect the component to be updated when switched in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants