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

keep-alive not working, resets data after change tab #5166

Closed
roelmagdaleno opened this issue Mar 6, 2019 · 5 comments · Fixed by #5188
Closed

keep-alive not working, resets data after change tab #5166

roelmagdaleno opened this issue Mar 6, 2019 · 5 comments · Fixed by #5188

Comments

@roelmagdaleno
Copy link

Version

v2.4.5

Reproduction link

https://codesandbox.io/s/9z8p69427r

Steps to reproduce

  1. Click on ROEL USER button to go to Profile tab, which is an url (/roelmagdaleno/profile)
  2. Go to Posts or Payments tab, when the component renders for the first time, it will show you the data.
  3. Go back to Profile and then go to posts or payments again.
  4. The current data that should kept alive has been reset to the initial values, an empty array.

What is expected ?

Keep alive the current tab data, so it won't make another API call.

What is actually happening?

The data is reset when user change the tab and enter again.

This bug report is available on Nuxt community (#c8776)
@ghost ghost added the cmty:bug-report label Mar 6, 2019
@ChenZhuoSteve
Copy link

ChenZhuoSteve commented Mar 6, 2019

https://codesandbox.io/s/73lqxj6436
posts.vue
image
when using keep-alive, data() will be called repeatedly when the component is activated.
I don't know if this is a bug.

@roelmagdaleno
Copy link
Author

Thank you, that works but I feel it is a little bit hacky.
In Vue.js, I could set the same behaviour without the if condition, weird.

Thanks!

@ChenZhuoSteve
Copy link

I don't think this issue should be closed. We don't know the root cause of this problem.
I am more inclined to think that this is a bug.

@roelmagdaleno
Copy link
Author

Sorry, I closed since no one else commented, but you're right. Maybe someone of the core team could decide if it is a bug or not.

@roelmagdaleno roelmagdaleno reopened this Mar 8, 2019
@clarkdo
Copy link
Member

clarkdo commented Mar 8, 2019

I'll have a look.

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

Successfully merging a pull request may close this issue.

4 participants