VuVue · Lesson 2 of 7
Reactivity: ref & reactive
Vue's reactivity system tracks which data a template uses and only re-renders what changed. `ref` wraps a primitive. `reactive` wraps an object. Know the difference and you'll avoid 90% of Vue gotchas.
✦ Tip
Rule of thumb: use `ref` for single values (number, string, array you'll replace), `reactive` for objects with multiple related fields (forms, config). Never destructure a `reactive` object — you lose reactivity. Use `toRefs(state)` if you need to destructure.
Rule of thumb: use `ref` for single values (number, string, array you'll replace), `reactive` for objects with multiple related fields (forms, config). Never destructure a `reactive` object — you lose reactivity. Use `toRefs(state)` if you need to destructure.