Last active
August 17, 2017 10:20
-
-
Save vdsabev/0d7d9aaf49e46b6c79479b53badcf411 to your computer and use it in GitHub Desktop.
Exploring Unidirectional Components in Mithril
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Counter = ({ attrs: { count = 0 } }) => { | |
const decrement = () => count--; | |
const increment = () => count++; | |
return { | |
view: () => | |
<div> | |
<h1>{count}</h1> | |
<button onclick={decrement} disabled={count <= 0}>-</button> | |
<button onclick={increment}>+</button> | |
</div> | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment