A hyperscript-like interface for Incremental DOM
Use h
to create render functions, and call them within patch
:
var h = require('incremental-hyperscript').h
var patch = require('incremental-dom').patch
function render(data) {
var text = (data.shouldSpeakToUniverse) ? 'Hello universe!' : 'Hello world!'
return h('div', {style: {color: 'red'}}, text)
}
var someData = {shouldSpeakToUniverse: false}
patch(myElement, render(someData))
var otherData = {shouldSpeakToUniverse: true}
patch(myElement, render(otherData))
tagName
(required) - A string representing a tag name (e.g.,span
).properties
(optional) - An object specifying properties (and their corresponding values) to be set on the element.children
(optional) - A string, function, or array (of strings and/or functions). If a string, a single text node child will be rendered. If a function, a single child element (created and returned by the function) will be rendered. If an array, several children (either text node or elements) will be rendered.
Returns a render function to be called within patch
.
With npm installed, run
$ npm install --save incremental-hyperscript incremental-dom
incremental-hyperscript was inspired by hyperscript, virtual-dom, and React.
Apache-2.0