ref or reactive?
ref and reactive both make state reactive, and both re-render the component
when the state changes. The difference is shape.
ref wraps a single value — a number, a string, an object. You reach the value
through .value in JavaScript, and Vue unwraps it in the template:
const count = ref(0);
count.value += 1;
reactive wraps an object and tracks each property. You read and write the
properties directly, with no .value:
const state = reactive({ count: 0, name: 'Vue' });
state.count += 1;
Two practical rules follow. First, reactive only works on objects: pass it a
number and it cannot track anything, so use ref for primitives. Second, a
reactive object cannot be reassigned wholesale — state = { ... } drops the
proxy and the link. A ref can: count.value = newObject stays reactive.
When in doubt, reach for ref. It works for every value, it survives
reassignment, and it is the form you pass around and destructure. Choose
reactive when a group of properties genuinely belongs together and you want to
read them without .value.
You are about to answer a short quiz on choosing between the two.