Problem Statement
Compare reactive() and ref(). When do you use each?
Explanation
Use ref() for a single primitive or when you need a value wrapper with .value. Use reactive() to make an object or array deeply reactive with proxy semantics. For reassigning an object wholesale, prefer ref with an object to avoid caveats of reactive shallow replacement.
Code Solution
SolutionRead Only
const n = ref(0) // n.value
const state = reactive({ user: { name: 'Evan' } })
// Whole-object replace pattern
const obj = ref({ a: 1 }); obj.value = { a: 2 }