--- title: Keep Props Stable to Minimize Child Re-renders impact: HIGH impactDescription: Passing changing props to list items causes ALL children to re-render unnecessarily type: efficiency tags: [vue3, performance, props, v-for, re-renders, optimization] --- # Keep Props Stable to Minimize Child Re-renders **Impact: HIGH** - When props passed to child components change, Vue must re-render those components. Passing derived values like `activeId` to every list item causes all items to re-render when activeId changes, even if only one item's active state actually changed. Move comparison logic to the parent and pass the boolean result instead. This is one of the most impactful update performance optimizations in Vue. ## Task Checklist - [ ] Avoid passing parent-level state that all children compare against (like `activeId`) - [ ] Pre-compute derived boolean props in the parent (like `:active="item.id === activeId"`) - [ ] Profile re-renders using Vue DevTools to identify prop stability issues - [ ] Consider this pattern especially critical for large lists **Incorrect:** ```vue ``` ```vue ``` **Correct:** ```vue ``` ```vue ``` ## Common Patterns That Cause Prop Instability ```vue /> /> ``` ## Performance Impact Example | Scenario | Props Changed | Components Re-rendered | |----------|---------------|------------------------| | 100 items, pass `activeId` | 100 | 100 (all) | | 100 items, pass `:active` boolean | 2 | 2 (only changed) | | 1000 items, pass `activeId` | 1000 | 1000 (all) | | 1000 items, pass `:active` boolean | 2 | 2 (only changed) | ## Reference - [Vue.js Performance - Props Stability](https://vuejs.org/guide/best-practices/performance.html#props-stability)