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

Component in keep alive receives activated event when being deactivated #5323

Closed
nicolas-t opened this issue Jan 25, 2022 · 3 comments
Closed
Labels
need more info Further information is requested scope: keep-alive

Comments

@nicolas-t
Copy link

Version

3.2.29

Reproduction link

code : github.com
demo : netlify.com

Steps to reproduce

  1. Click https://vue-3-keep-alive-lifecycle.netlify.app/
  2. Open devtools, console tab.
  3. Click About link.
  4. Clear console.
  5. Click Home link.

What is expected?

Since it's being deactivated NestedAbout component should not receive the activated lifecycle event

What is actually happening?

NestedAbout component is receiving the activated lifecycle event


We can also notice that NestedHome is mounted twice, as reported here:
vuejs/router#626 (comment)

@posva
Copy link
Member

posva commented Feb 9, 2022

Can you create a reproduction without the router? This will help to move forward. You can use this playground as a starting point

@nicolas-t
Copy link
Author

nicolas-t commented Feb 10, 2022

Hello @posva,

I can't reproduce the bug without vue-router (activated event is not called on deactivated component anymore)
I let you check if my repro is valid, but I think this issue can be moved to the vue-router repository.
SFC playground

@posva
Copy link
Member

posva commented Feb 10, 2022

The repro is not exactly the same because, in Vue Router, nested components are dynamic and keep rendering (cf the issue you linked) which is why they get activated/deactivated, the nested children are rendered twice. It's similar (but not exactly the same) as this

Let's close this in favor of #5386 because solving that would solve this too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need more info Further information is requested scope: keep-alive
Projects
None yet
Development

No branches or pull requests

3 participants