In Vue 3, reactive() works great for objects, but what about primitive values like numbers, strings, and booleans?
That's where ref() comes in. It wraps a primitive in a reactive container object with a single .value property:
const count = ref(0);
effect(() => {
console.log('count:', count.value); // → "count: 0"
});
count.value = 1; // triggers the effect → "count: 1"
count.value = 2; // → "count: 2"The simplest correct implementation is just:
function ref(initialValue) {
return reactive({ value: initialValue });
}But you need to implement reactive() and effect() to make it work.
Implement ref(initialValue), effect(fn), and _reset().
The solve(op, ...args) harness is provided — do not modify it.
Sample tests