vdom-render-to v0.10.0
vdom-render-to
Convenience functions for creating and updating virtual-dom trees.
Motivation
Streamlining the steps to create a DOM tree from a virtual-dom representation and updating it.
Installation
npm install --save vdom-render-to
Use
var h = require('virtual-dom/h');var vdomRenderTo = require('vdom-render-to');Select the DOM element that will be updated when rendering.
The element itself will be updated, not just its children.var update = vdomRenderTo(element);var vtree;Do any processing necessary to generate the first virtual-dom tree (vtree).
vtree = h('h1', 'hello world');Update the element with the vtree:
update = update(vtree);
Note thatupdate, the function returned byvdomRenderTois different than the one returned by subsequent calls toupdate. Instead of using different names, likecreateandupdateis more convenient to just update the same function reference after every call.Repeat steps 3 and 4 whenever you need to re-render. e.g.: on user interaction.
vdom-render-to Copyright 2015 © DEADB17 DEADB17@gmail.com
Distributed under the MIT license.
11 years ago