The object to make reactive
Reactive proxy of the input object
const state = reactive({ count: 0 });
effect(() => {
console.log('Count:', state.count);
});
state.count++;
// array
const array = reactive({ items: [1, 2, 3] });
array.items.push(4); // ❌ NOT reactive
array.items = [...array.items, 4]; // ✔️ Reactive
// object
const object = reactive({ user: { name: 'John' } });
object.user.name = 'Bob'; // ❌ NOT reactive
object.user = { name: 'Jane' }; // ✔️ Reactive
const state = reactive({});
// track
effect(() => {
state.a; // ✔️ get property
'a' in state; // ✔️ has property
Object.keys(state); // ✔️ iterate properties
});
// trigger
state.a = 0; // ✔️ add or set property
delete state.a; // ✔️ delete property
Creates a reactive proxy for an object that tracks property access and modifications