-
-
Save yoshuawuyts/721b4a13ea31e42106e8 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 h.html(`<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 h.html(` | |
<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