html-vdom
v2.7.0
Published
JSX virtual DOM using standard HTML
Downloads
126
Readme
JSX virtual DOM using standard HTML
Examples
/** @jsxImportSource html-vdom */
import { render } from 'html-vdom'
import { fromElement } from 'html-vdom/from-element'
class FooElement extends HTMLElement {
root = this.attachShadow({ mode: 'open' })
set who(name: string) {
this.root.innerHTML = 'Hello, ' + name
}
}
const Foo = fromElement(FooElement)
render(<Foo who="world" />, document.body)
/** @jsxImportSource html-vdom */
import { $, render } from 'html-vdom'
const App: $<{ who: string }> = ({ who }) => <h1>Hello, {who}!</h1>
render(<App who="world" />, document.body)
/** @jsxImportSource html-vdom */
import { $, Hook, hook, render } from 'html-vdom'
let greeting = 'Hello'
let update: Hook
const App: $<{ who: string }> = ({ who }) => {
update = hook
return <h1>{greeting}, {who}!</h1>
}
render(<App who="world" />, document.body)
setTimeout(() => {
greeting = 'Hiya'
update()
}, 500)