Skip to content

Instantly share code, notes, and snippets.

View rglover's full-sized avatar

Ryan Glover rglover

View GitHub Profile
@rglover
rglover / jsx-render.tsx
Created June 9, 2021 19:54 — forked from Dynalon/jsx-render.tsx
Sample JSX to HTMLElement renderer in TypeScript
// Tiny JSX renderer in TypeScript inspired by plain-jxs: https://github.com/callumlocke/plain-jsx
// Babel would allow you to specify the factory function as special inline comment:
/** @jsx JSXrender */
let JSXrender = (tagName: string, attributes?: { [key: string]: any }, ...children: Array<HTMLElement |  string>): HTMLElement => {
if (!tagName || typeof tagName !== 'string')
throw new Error("tagName has to be defined, non-empty string");