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

Sub RouterView component will render multiple times when using with KeepAlive #4708

Closed
ustbhuangyi opened this issue Sep 30, 2021 · 1 comment

Comments

@ustbhuangyi
Copy link
Contributor

Version

3.2.19

Reproduction link

github.com

Steps to reproduce

  1. Visit Home Page.
  2. Jump to the About Page.
  3. Click button to render Sub Page.

What is expected?

Sub Page component render only once. The create hook called once.

What is actually happening?

Sub Page component render twice, and the created hook called twice.


I have did some research about this issue, hope it helps.

Since the Home Page is keep-alived,so when jump to the About Page, the Home Page won't be unmounted, and the render effect of the Home Page's sub RouterView won't be cleared.

And then when we click this button, the currentRoute of our router changed, which will trigger all the RouterView to be re rendered. Under normal conditions, the RouterView component inside About component will be render as the Sub component. But unfortunately, the RouterView component inside Home component also be re rendered as the Sub component.

@posva
Copy link
Member

posva commented Sep 30, 2021

Duplicate of vuejs/router#626

@posva posva marked this as a duplicate of vuejs/router#626 Sep 30, 2021
@posva posva closed this as completed Sep 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants