Overview
Alveron is an Elm-inspired state management library for React that supports asynchronous side effects as a first class citizen.
It's super lightweight at only 1.2kb and uses React's useState under the hood.
Installation
# yarnyarn add alveron
# pnpmpnpm add alveron
# npmnpm i --save alveron
The Gist
import * as React from 'react'import { useStore } from 'alveron'
const model = 0const actions = { increment: (prevState) => [prevState + 1], decrement: (prevState) => [prevState - 1],}
function Counter() { const [state, { increment, decrement }] = useStore(actions, model)
return ( <div> Count: {state} <button onClick={() => increment()}>+</button> <button onClick={() => decrement()}>-</button> </div> )}