0.1.0 • Published 5 years ago
use-easy-state v0.1.0
use-easy-state
React State Hook alternative that updates when state object is directly modified.
No need for an update()
method, make changes to the state object directly.
Uses on-change, and depends on Proxy.
Install
npm i use-easy-state
Usage
const useState = require(use-easy-state)
module.exports = () => {
// Initial value must be a (proxy-able) object, natives won't work
const state = useState({ counter: 0 })
return (
<button onClick={ () => state.counter++ }>
`You have pressed this button ${state.counter} times`
</button>
)
}
0.1.0
5 years ago