Closed
Description
Vue version
3.3.4
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-9dgxah?file=src%2FApp.vue
Steps to reproduce
- Open reproduction and click plus button.
- The
update
become2
from0
. (expected is1
)
What is expected?
According the following code, when count
update once, the watcher should just run once.
import { ref, computed, watch } from 'vue';
const update = ref(0);
const count = ref(0);
const sync1 = computed(() => count.value);
const sync2 = computed(() => count.value);
const sync = computed(() => ({
sync1: sync1.value,
sync2: sync2.value,
}));
watch(
sync,
(value) => {
update.value++;
},
{
flush: 'sync',
}
);
What is actually happening?
The watcher ran twice!
System Info
System:
OS: macOS 11.6
CPU: (8) arm64 Apple M1
Memory: 90.47 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
Browsers:
Firefox: 116.0.2
Safari: 14.1.2
Safari Technology Preview: 15.4
npmPackages:
vue: ^3.3.4 => 3.3.4
Any additional comments?
No response