valtio-reactive makes Valtio a reactive library
See: pmndrs/valtio#949
npm install valtio valtio-reactive
import { proxy } from 'valtio/vanilla';
import { batch, computed, effect } from 'valtio-reactive';
const state = proxy({ count: 1 });
const derived = computed({
double: () => state.count * 2,
});
effect(() => {
console.log('double count:', derived.double);
});
setInterval(() => {
batch(() => {
state.count++;
state.count++;
});
}, 1000);