Vue · VUE0040

Pass list items a computed comparison

Finds v-for children that receive the same parent value on every item and compare it with one of their own per-item props.
VUE0040vite-doctor/vueperformanceinfoNo fix

Run this rule

pnpm vite-doctor . --framework vue --extends auto,vue/strict --rules vue/perf/prefer-stable-list-props

Why it matters

A Vue child component re-renders when any prop it receives changes. When every item of a v-for gets the same parent value, such as ="activeId", and compares it with its own per-item prop, each change of that value re-renders every item in the list, even though only the items whose comparison result flips have anything new to show. The cost grows with the list length.

Compare in the parent and pass the result as a boolean prop, such as ="item.id === activeId", and have the child read that prop instead of comparing two props. Most items then receive an unchanged prop and skip re-rendering.

Example

Pass the comparison result to list items

Before

<!-- ListItem.vue -->
<script setup lang="ts">
const props = defineProps<{ id: number; activeId: number | null }>()
const active = computed(() => props.id === props.activeId)
</script>

<!-- List.vue -->
<template>
  <ListItem v-for="item in list" :key="item.id" :id="item.id" :active-id="activeId" />
</template>

After

<!-- ListItem.vue -->
<script setup lang="ts">
defineProps<{ id: number; active: boolean }>()
</script>

<!-- List.vue -->
<template>
  <ListItem v-for="item in list" :key="item.id" :id="item.id" :active="item.id === activeId" />
</template>
Copyright © 2026