UNPKG

725 BJavaScriptView Raw
1import {h} from './h'
2import {patch} from './patch'
3
4/**
5 * @description 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.
6 * @example Update Title tag into section:
7 * const element = mount(<Title message='Hello World!'/>, 'section')
8 * // Pass the captured element to the render function:
9 * render(<Title message='Hello Everyone!'/>, element)
10 * @param {function} tag A JSX tag or hyperscript function to render.
11 * @param {HTMLElement|boolean} [element] The element in the DOM which will be updated.
12 * @returns {HTMLElement} The base element of the rendered tag.
13 */
14export function render(tag, element) {
15 return patch(tag, element)
16}