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 calls update hook after it is destroyed #8076

Closed
BL-Lac149597870 opened this issue Apr 24, 2018 · 7 comments · Fixed by #8381 or #9171
Closed

component calls update hook after it is destroyed #8076

BL-Lac149597870 opened this issue Apr 24, 2018 · 7 comments · Fixed by #8381 or #9171
Assignees

Comments

@BL-Lac149597870
Copy link

BL-Lac149597870 commented Apr 24, 2018

Version

2.5.2

Reproduction link

https://codesandbox.io/s/ympx4pk72z

Steps to reproduce

1、click the home link
2、click the test link

What is expected?

after the Home component destroyed,its updated hook should not be called

What is actually happening?

after the Home component destroyed,its updated hook is called


here is the log information

Home beforeCreate
Home created
Home beforeMount
Home mounted
Test beforeCreate
Test created
Test beforeMount
Home beforeDestroy
Home destroyed
Test mounted
Home updated

why the Home component can call updated hook after it is destroyed?
Is Vue designed to do so?

@mbj36
Copy link

mbj36 commented Apr 25, 2018

@BL-Lac149597870 In your reproduction link, you have not defined your components as .vue component.

@BL-Lac149597870
Copy link
Author

@mbj36 my bad.Now i have just corrected the mistake and changed the repo link,but the problem still remains...

@mbj36
Copy link

mbj36 commented Apr 26, 2018

@BL-Lac149597870 It's always better to use computed property or watcher - See the api docs here - https://vuejs.org/v2/api/#updated

@BL-Lac149597870
Copy link
Author

@mbj36 Thank you for your reply. But I didn't perform any DOM-dependent operations when the updated hook was called.And according to Vue lifecycle,after one component is destroyed,its updated hook shouldn't be called.But in my repo,this condition happens.I can't figure out how this happens.

@shockw4ver
Copy link

Met this problem, too.
Any news for this?😂
@BL-Lac149597870

@fnlctrl fnlctrl added the bug label May 14, 2018
@BL-Lac149597870
Copy link
Author

@shockw4ver Maybe we can work it out together,hahaha~

@therealpecus
Copy link
Contributor

I hate to bring bad news, but the fix only triggers the update part of the lifecycle, leaving beforeUpdate still being invoked after the component is destroyed.

Use the sandbox above with "vue": "^2.5.18-beta.0", to verify
(xposted on the PR accepted)

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