Vue · Reactivity
Finds in-place changes to a plain object, array, `Map`, or `Set` inside a `const` `shallowRef()`, such as `list.value.push(item)`. Doctor looks for a template, `computed()`, or watcher in the same file that reads the ref, and for a change that can run after setup, such as one in a mounted hook, Nuxt’s `onNuxtReady()`, a post-flush watcher, a timer, or a template event handler. It leaves synchronous setup writes, accessors, and receivers that may have been replaced with reactive values alone. A `triggerRef()` call for the ref, a `.value` assignment in the same function, a template that replaces the ref's value, or passing the ref to code Doctor cannot follow keeps it quiet. Refs imported from another file are not followed.
vite-doctor/vuereactivityerrorSuggestion
Why it happens
A shallowRef() tracks only its .value property: the getter tracks value and only the .value setter or triggerRef() triggers. The object inside stays a plain object, so pushing to an array or setting a property in it notifies nothing. The template, computed() values, and watchers that read the ref keep showing the old contents until something unrelated re-runs them, and a computed() keeps returning its cached result.
Fix
Call triggerRef(ref) after changing the value in place, or assign a new object or array to .value, such as list.value = [...list.value, item]. Use ref() when the value should track nested changes.
Example
Replace the value or trigger the ref
Before
<script setup lang="ts">
import { shallowRef } from 'vue'
const todos = shallowRef<string[]>([])
function add(todo: string) {
todos.value.push(todo)
}
</script>
<template>
<button @click="add('Write docs')">Add</button>
<p>{{ todos.length }} todos</p>
</template>
After
<script setup lang="ts">
import { shallowRef } from 'vue'
const todos = shallowRef<string[]>([])
function add(todo: string) {
todos.value = [...todos.value, todo]
}
</script>
<template>
<button @click="add('Write docs')">Add</button>
<p>{{ todos.length }} todos</p>
</template>
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vue --rules vue/reactivity/no-shallow-ref-deep-mutation