vdom-render-to
v0.10.0
Published
Convenience functions for creating and updating virtual-dom trees
Downloads
2
Maintainers
Readme
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 byvdomRenderTo
is different than the one returned by subsequent calls toupdate
. Instead of using different names, likecreate
andupdate
is 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 [email protected]
Distributed under the MIT license.