Choo component API preview. See discussion for more information.
var choo = require('choo')
var app = choo()
app.use(require('choo-component-preview')())
app.mount('body')
var Component = require('nanocomponent')
var html = require('choo/html')
module.exports = class Article extends Component {
static identity (article) {
return `article-${article.id}`
}
createElement (article) {
return html`
<article>
<h2>${article.title}</h2>
<p>${article.body}</p>
</article>
`
}
update () {
return false
}
}
var Article = require('./components/article')
var Header = require('./components/header')
var Footer = require('./components/footer')
module.exports = function (state, emit, render) {
return html`
<body
${render(Header)}
${state.articles.map(article => render(Article, article))}
${render(Footer)}
</body
`
}
$ npm install choo-component-preview