Skip to content

Instantly share code, notes, and snippets.

@BenjaminVerble
Created July 30, 2015 19:50
Show Gist options
  • Save BenjaminVerble/1a60c09a3e853d9cb478 to your computer and use it in GitHub Desktop.
Save BenjaminVerble/1a60c09a3e853d9cb478 to your computer and use it in GitHub Desktop.
// 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