Skip to main content
variable renderElement
import { renderElement } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Renders the given DOM tree in the specified DOM element.

Destructure the first argument into type and props, use type to determine if the given element is a text element. Based on the element's type, use either Document.createTextNode() or Document.createElement() to create the DOM element. Use Object.keys(props, adding attributes to the DOM element and setting event listeners, as necessary. Use recursion to render props.children, if any. Finally, use Node.appendChild() to append the DOM element to the specified container.

type

(unnamed 0: IElement, container: any) => unknown