Created
July 30, 2015 19:50
-
-
Save BenjaminVerble/1a60c09a3e853d9cb478 to your computer and use it in GitHub Desktop.
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
// main.js | |
const vel = require('vel') | |
const testElement = require('./test-element') | |
const el = vel(function (h, state) { | |
return <div> | |
<h1>clicked {String(state.n)} times</h1> | |
<button onclick={onclick}>click me!</button> | |
{testElement(h, state, el)} | |
</div> | |
function onclick () { | |
el({ n: state.n + 1 }) | |
} | |
}) | |
document.querySelector('#content').appendChild(el({ n: 0 })) | |
// test-element.js | |
module.exports = function (h, state, el) { | |
return <button onclick={onclick}>child button adds two instead</button> | |
function onclick () { | |
el({ n: state.n + 2 }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment