made with esnextbin
Last active
February 9, 2016 00:03
-
-
Save developit/d804796c481218488309 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>ESNextbin Sketch</title> | |
| <style> | |
| body > div { padding:40px; } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- put markup and other contents here --> | |
| </body> | |
| </html> |
This file contains hidden or 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
| import { h, render } from 'preact-cycle'; | |
| /** @jsx h */ | |
| const App = ({ value, mutation }) => ( | |
| <div> | |
| <button onClick={ mutation('value', v => v+1) }>Increment</button> | |
| <p>Value: { value }</p> | |
| </div> | |
| ); | |
| render(App, { value: 0 }, document.body); |
This file contains hidden or 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
| { | |
| "name": "esnextbin-sketch", | |
| "version": "0.0.0", | |
| "dependencies": { | |
| "preact-cycle": "0.1.1" | |
| } | |
| } |
This file contains hidden or 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
| 'use strict'; | |
| var _preactCycle = require('preact-cycle'); | |
| /** @jsx h */ | |
| var App = function App(_ref) { | |
| var value = _ref.value; | |
| var mutation = _ref.mutation; | |
| return (0, _preactCycle.h)( | |
| 'div', | |
| null, | |
| (0, _preactCycle.h)( | |
| 'button', | |
| { onClick: mutation('value', function (v) { | |
| return v + 1; | |
| }) }, | |
| 'Increment' | |
| ), | |
| (0, _preactCycle.h)( | |
| 'p', | |
| null, | |
| 'Value: ', | |
| value | |
| ) | |
| ); | |
| }; | |
| (0, _preactCycle.render)(App, { value: 0 }, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment