Subscribe on changes!

[bug] triggerRef does not trigger props reactivity

avatar
Dec 1st 2023

Vue version

3.3.4

Link to minimal reproduction

npm create vue@latest

Steps to reproduce

npm create vue@latest

App.vue

<template>
  <div>
    parent: {{ something.value }}
  </div>
  <br />
  <div>
    <Test :something="something"/>
  </div>
</template>

<script setup>
import { shallowRef, triggerRef } from 'vue';
import Test from './Test.vue'

const something = shallowRef({
  value: 0,
});

setInterval(() => {
  something.value.value++;
  triggerRef(something);
}, 5000)
</script>

./Test.vue

<template>
  child: {{ something.value }}
</template>

<script setup>
const props = defineProps({
  something: {
    required: true,
    type: Object,
  }
});
</script>

result: image

What is expected?

I would assume that triggerRef would also trigger specific passed down prop (thus triggering reactivity)

What is actually happening?

it doesn't

System Info

No response

Any additional comments?

No response

avatar
Dec 1st 2023

This is expected behaviour. While the ref is being triggered, the child component doesn't receive the ref, it only receives its value - and if that value itself is still the same, the child has no reason to update.