Skip to content

Instantly share code, notes, and snippets.

@vdsabev
Last active August 17, 2017 10:20
Show Gist options
  • Save vdsabev/0d7d9aaf49e46b6c79479b53badcf411 to your computer and use it in GitHub Desktop.
Save vdsabev/0d7d9aaf49e46b6c79479b53badcf411 to your computer and use it in GitHub Desktop.
Exploring Unidirectional Components in Mithril
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