Vue 3.2 / Watcher for Prop not working in SFC + Script Setup

Viewed 1266

My setup is as follows:

<script setup lang="ts">
const props = defineProps({
  count: {
    type: Number,
    default: 0
  }
})

const { count } = toRefs(props)

watch(count, (newValue, oldValue) => {
  console.log(newValue, oldValue);
})
</script>

The console log is never run.

If I on the other hand set { immediate: true }, it does run but only logs out the new value - old is always undefined.

What am I doing wrong here?

Thank you!

0 Answers
Related