Skip to content

Instantly share code, notes, and snippets.

@JamesUlph
Created February 9, 2016 06:58
Show Gist options
  • Save JamesUlph/a5996cdfa887f5ad37f5 to your computer and use it in GitHub Desktop.
Save JamesUlph/a5996cdfa887f5ad37f5 to your computer and use it in GitHub Desktop.

Revisions

  1. JamesUlph created this gist Feb 9, 2016.
    1 change: 1 addition & 0 deletions esnextbin.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    made with [esnextbin](http://esnextb.in)
    13 changes: 13 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <!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>
    13 changes: 13 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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>

    <p>{value}</p>
    </div>
    );

    render(App, { value: 0 }, document.body);
    7 changes: 7 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    {
    "name": "esnextbin-sketch",
    "version": "0.0.0",
    "dependencies": {
    "preact-cycle": "0.1.1"
    }
    }
    34 changes: 34 additions & 0 deletions transpiled.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    '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.h)(
    'p',
    null,
    value
    )
    );
    };

    (0, _preactCycle.render)(App, { value: 0 }, document.body);