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

isDeactivated could not reactived timely #5205

Closed
LoveofRedMoon opened this issue Jan 4, 2022 · 1 comment
Closed

isDeactivated could not reactived timely #5205

LoveofRedMoon opened this issue Jan 4, 2022 · 1 comment

Comments

@LoveofRedMoon
Copy link

Version

3.2.26

Reproduction link

github.com

Steps to reproduce

provide two ways.

first: with vue-router@next
click 'To Test2'
click 'To Test1'
click 'To Tesr2'

second: without vue-router
click 'show Test4'
click 'show Test3'
click 'show Test4'

What is expected?

first: with vue-router@next
click 'To Test2' // console Test1 isDeactivated true
click 'To Test1' // console Test1 isDeactivated false \nTest2 isDeactivated true
click 'To Tesr2' // console Test1 isDeactivated true \nTest2 isDeactivated false

second: without vue-router
click 'show Test4'
click 'show Test3' // console Test3 isDeactivated false
click 'show Test4' // console Test4 isDeactivated false

What is actually happening?

first: with vue-router@next
click 'To Test2' // console Test1 isDeactivated false
click 'To Test1' // console Test1 isDeactivated true \nTest2 isDeactivated false
click 'To Tesr2' // console Test1 isDeactivated false \nTest2 isDeactivated true

second: without vue-router
click 'show Test4'
click 'show Test3' // console Test3 isDeactivated true
click 'show Test4' // console Test4 isDeactivated true


Actually, when add nextTick, it will show correctly, it may caused by keep-alive which post last queue

@LinusBorg
Copy link
Member

I don't see this why this should be seen as a bug. You should not be relying on

  1. internal APIs like instance.deactivated
  2. assumptions about timing in Vue's asynchronous update process that are not documented.

You should rather be using onActivated/onDeactivated to react to when an instance is actually being (de-)activated

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

No branches or pull requests

2 participants