Watchers in nested elements in keep alive are called twice
Version
3.2.26
Reproduction link
code : github.com demo : netlify.com
Steps to reproduce
- Click https://vue-3-watcher-called-twice.netlify.app/home/nested
- Open devtools on the console tab.
- Click About link.
- Click "Modify shared state".
What is expected?
Modifying state should trigger related watchers once.
What is actually happening?
Modifying state triggers related watchers twice.
Related topic : https://forum.vuejs.org/t/vue-3-watcher-called-twice/125548
This is because when for example "home" is active, keepAlive
caches About
-> RouterView
(RounterView
renders NestedHome
), it results in two NestedHome
instances.
Closing in favor of https://github.com/vuejs/core/issues/5386 without vue-router involved