diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-04 11:50:26 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-04 11:50:26 +0200 |
commit | 30b577138dda685f65a8529be1866afa6e321845 (patch) | |
tree | bfa92ee3ab485a6b11f86731777ecf5c5d166bab /src/render.js |
Squashed 'thirdparty/preact/' content from commit b2d90cc
git-subtree-dir: thirdparty/preact
git-subtree-split: b2d90cc116f1d1998f7a7c98dc6986bf4c1841f4
Diffstat (limited to 'src/render.js')
-rw-r--r-- | src/render.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/render.js b/src/render.js new file mode 100644 index 000000000..e0e8526ec --- /dev/null +++ b/src/render.js @@ -0,0 +1,20 @@ +import { diff } from './vdom/diff'; + +/** Render JSX into a `parent` Element. + * @param {VNode} vnode A (JSX) VNode to render + * @param {Element} parent DOM element to render into + * @param {Element} [merge] Attempt to re-use an existing DOM tree rooted at `merge` + * @public + * + * @example + * // render a div into <body>: + * render(<div id="hello">hello!</div>, document.body); + * + * @example + * // render a "Thing" component into #foo: + * const Thing = ({ name }) => <span>{ name }</span>; + * render(<Thing name="one" />, document.querySelector('#foo')); + */ +export function render(vnode, parent, merge) { + return diff(merge, vnode, {}, false, parent); +} |