Package Exports
- hypercomponent
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hypercomponent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hypercomponent
Fast and light component system, backed by hyperHTML ⚡
Usage
Basic
const hyperHTML = require('hyperhtml')
const component = require('hypercomponent')
const app = hyperHTML.bind(document.body)
const Button = component((render, text) => render`
<button>
${text}
</button>
`)
const myButton = Button()
app`${myButton.render('Hello world!')}`
setTimeout(() => myButton.render('Hello there!'), 1000)
Subscribe to lifecycle events
const hyperHTML = require('hyperhtml')
const component = require('hypercomponent')
const app = hyperHTML.bind(document.body)
const Button = component({
load: (e) => {
console.log(e, 'loaded')
},
unload: (e) => {
console.log(e, 'unloaded')
},
render: (render, text) => render`
<button onclick="${(e) => e.target.parentNode.removeChild(e.target)}">
${text}
</button>
`
})
const button1 = Button()
const button2 = Button()
app`${[
button1.render('Hello world!'),
button2.render('Hello again!')
]}`
See also:
License
MIT