@snugjs/html
v3.1.0
Published
Create HTML elements and fragments using JSX.
Downloads
28
Readme
@snugjs/html
Create HTML elements and fragments using JSX.
Installation
npm install @snugjs/html
Hello World
import {createElement} from '@snugjs/html';
document.body.appendChild(<h1>Hello, World!</h1>);
document.body.appendChild(createElement('h1', {}, 'Hello, World!'));
<Hello />
Element Factory
import {createElement, createElementFactory} from '@snugjs/html';
const Hello = createElementFactory('h1', (element, childNodes) => {
element.replaceChildren('Hello, ', ...childNodes, '!');
});
document.body.appendChild(<Hello>World</Hello>);
TypeScript Configuration
{
"jsx": "react",
"jsxFactory": "createElement",
"jsxFragmentFactory": "createFragment"
}