--- title: Avoid Excessive Re-renders from Misused Watchers impact: HIGH impactDescription: Using watch instead of computed, or deep watchers unnecessarily, triggers excessive component re-renders type: gotcha tags: [vue3, rendering, performance, watch, computed, reactivity, re-renders] --- # Avoid Excessive Re-renders from Misused Watchers **Impact: HIGH** - Improper use of watchers is a common cause of performance issues. Deep watchers track every nested property change, and using watch when computed would suffice creates unnecessary reactive updates that trigger re-renders. ## Task Checklist - [ ] Use `computed` for derived values, not `watch` + manual state updates - [ ] Avoid `deep: true` on large objects unless absolutely necessary - [ ] When deep watching is needed, watch specific nested paths instead - [ ] Never trigger state changes inside watch that cause the watch to re-fire **Incorrect:** ```vue ``` **Correct:** ```vue ``` ## When to Use Watch vs Computed | Use Case | Use This | |----------|----------| | Derive a value from state | `computed` | | Format/transform data for display | `computed` | | Perform side effects (API calls, DOM updates) | `watch` | | React to route changes | `watch` | | Sync with external systems | `watch` | ## Infinite Loop from Watch ```vue ``` ## Efficient Deep Watching When you must watch complex objects: ```vue ``` ## Array Mutation Gotcha ```vue ``` ## Reference - [Vue.js Watchers](https://vuejs.org/guide/essentials/watchers.html) - [Vue.js Computed Properties](https://vuejs.org/guide/essentials/computed.html) - [Vue.js Performance - Reactivity](https://vuejs.org/guide/best-practices/performance.html#reduce-reactivity-overhead-for-large-immutable-structures)