Unistore Hooks for Preact
Experimental hooks-based bindings for Unistore. Available on npm:
npm i unistore-hooks
Note: this should also work with React, just alias
"preact"
and"preact/hooks"
to"react"
in your bundler.
Usage
;;; const store = ; const ACTIONS = { return count: count + 1 ; } { return count: count - 1 ; } { return count: newCount ; }; { // get state values from the store: const count = ; // bind + return all actions: const increment decrement = ; // or create custom bound actions: const reset add10 = ; // or declare parameterized actions: const max = propsmax || 999; const setToMax = ; return <div> <button onClick=decrement>-1</button> Current value: count <button onClick=increment>+1</button> <button onClick=reset>Reset</button> <button onClick=setToMax>Max</button> </div> ;} ;