Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Virtual DOM example
var tree = render(count); // We need an initial tree
var rootNode = createElement(tree); // Create an initial root DOM node ...
document.body.appendChild(rootNode); // ... and it should be in the document
setInterval(function () {
count++;
var newTree = render(count);
var patches = diff(tree, newTree);
rootNode = patch(rootNode, patches);
tree = newTree;
}, 1000);
// jsx example
const element = (
<div>
<h1>Hello!</h1>
<h2>Good to see you here.</h2>
</div>
);
render(element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment