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

Effects are re-executed when leaving a page #1562

Closed
adamjedlicka opened this issue Sep 27, 2022 · 1 comment
Closed

Effects are re-executed when leaving a page #1562

adamjedlicka opened this issue Sep 27, 2022 · 1 comment

Comments

@adamjedlicka
Copy link

Version

4.1.5

Reproduction link

jsfiddle.net/djw2mbhk/

Steps to reproduce

When going from one page to another (category.vue to product.vue), effects from the old page are executed. Watch does not behave this way as fixed in here: vuejs/core#2291

What is expected?

When switching from one page to another, only effects from the new page are executed.

What is actually happening?

When switching from one page to another, effects from both pages are executed.

@posva
Copy link
Member

posva commented Sep 28, 2022

This is expected as effect is immediate and the same behavior happens in vue. This is because they are immediate so the same happens with immediate: true. Use a regular watch or flush: 'post' instead and it will work as described in the issue even with vue-router in your reproduction

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