valtio-reactive
Version:
valtio-reactive makes Valtio a reactive library
43 lines (30 loc) • 1.07 kB
Markdown
# valtio-reactive
[](https://github.com/valtiojs/valtio-reactive/actions?query=workflow%3ACI)
[](https://www.npmjs.com/package/valtio-reactive)
[](https://bundlephobia.com/result?p=valtio-reactive)
[](https://discord.gg/MrQdmzd)
valtio-reactive makes Valtio a reactive library
## Background
See: https://github.com/pmndrs/valtio/discussions/949
## Install
```bash
npm install valtio valtio-reactive
```
## Usage
```js
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);
```