Subscribe on changes!

Watchers in nested elements in keep alive are called twice

avatar
Jan 5th 2022

Version

3.2.26

Reproduction link

code : github.com demo : netlify.com

Steps to reproduce

  1. Click https://vue-3-watcher-called-twice.netlify.app/home/nested
  2. Open devtools on the console tab.
  3. Click About link.
  4. 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

avatar
Jan 18th 2022

This is because when for example "home" is active, keepAlive caches About -> RouterView (RounterView renders NestedHome), it results in two NestedHome instances. image

avatar
Jan 18th 2022

similar to #5252, because the children are not cached.

avatar
Jul 19th 2022

Closing in favor of https://github.com/vuejs/core/issues/5386 without vue-router involved