Skip to content

valtiojs/valtio-reactive

Repository files navigation

valtio-reactive

CI npm size discord

valtio-reactive makes Valtio a reactive library

Background

See: pmndrs/valtio#949

Install

npm install valtio valtio-reactive

Usage

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);

About

valtio-reactive makes Valtio a reactive library

Resources

License

Stars

Watchers

Forks

Packages

No packages published