vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

Route update unexpectedly triggers watchers #2022

Closed lwansbrough closed 1 year ago

lwansbrough commented 1 year ago

Reproduction

https://jsfiddle.net/sj1chxmd/2/

Steps to reproduce the bug

Observe behaviour in this repro (Vue 2.7): https://jsfiddle.net/sj1chxmd/2/ Then compare the behaviour in this repro (Vue 3): https://jsfiddle.net/sf2gutkr/1/

Expected behavior

The behaviour should be the same between the two examples.

Actual behavior

The presence of a reactive variable on the <router-view> in the Vue 3 version forces its descendants' watchers to update. I believe the correct behaviour should be the Vue 2.7 behaviour.

Additional information

Related:

posva commented 1 year ago

Duplicate of https://github.com/vuejs/core/issues/7030