Skip to content
A cartoon confused emoji-like face, this is the project logo.

Oh my, your store is in a right two and eight.

Minimal state boilerplate.
0
Counter.tsx
import { TwoAndEight, createReactStore } from '2n8'
class Store extends TwoAndEight {
count = 0
addClicked() {
this.count++
}
resetClicked() {
this.$reset('count')
}
}
const useStore = createReactStore(new Store())
const Counter = () => {
const count = useStore((s) => s.count)
const addClicked = useStore((s) => s.addClicked)
const resetClicked = useStore((s) => s.resetClicked)
return (
<div>
<span>{count}</span>
<button onClick={addClicked}>One up</button>
<button onClick={resetClicked}>Reset</button>
</div>
)
}