4

const state = proxy({
dur: 4,
count: 1
});
const incDur = () => {++state.dur};
const decDur = () => {--state.dur};
const incCount = () => {
++state.count;
setTimeout(incCount, 100 * state.dur);
};
incCount();
const snap = useSnapshot(state)
return (
<div>
<h3>{snap.dur}</h3>
<button
disabled={snap.dur <= 1}
onClick={decDur}>
-
</button>
<button
disabled={snap.dur >= 10}
onClick={incDur}>
+
</button>
</div>
);

Proxy state made simple

Get started

Proxy state made simple