UNPKG

686 BJavaScriptView Raw
1import { patch } from './vdom'
2
3/**
4 * A function to update a functional component already mounted in the DOM. The first argument can be either a JSX tag or an h function.
5 * @example Update Title tag into section:
6 * const element = mount(<Title message='Hello World!'/>, 'section')
7 * // Pass the captured element to the render function:
8 * render(<Title message='Hello Everyone!'/>, 'header')
9 * @param {() => import('./h').VNode} tag A JSX tag or hyperscript function to render.
10 * @param {Node} [element] The element in the DOM which will be updated.
11 * @return {Node} The base element of the rendered tag.
12 */
13export function render(tag, element) {
14 return patch(tag, element)
15}