Created
May 22, 2020 13:26
-
-
Save pauleveritt/16546c0cdf1ff747824973676b2d5760 to your computer and use it in GitHub Desktop.
htm preact integration for SSR VDOMs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Hello Bulma!</title> | |
<link rel="stylesheet" href="static/bulma.css"> | |
</head> | |
<body> | |
<section class="section"> | |
<div class="container"> | |
<h1 class="title"> | |
Hello World | |
</h1> | |
<p class="subtitle"> | |
My first website with <strong>Bulma</strong>! | |
</p> | |
</div> | |
</section> | |
<script type="module"> | |
import { html, render, h } from 'https://unpkg.com/htm/preact/standalone.module.js' | |
// Doesn't work | |
const vdom = h({ | |
type: 'h1', | |
props: { id: 'hello' }, | |
children: ['Hello world!'] | |
}) | |
// Works | |
const vdom2 = html`<a href="/">Hello!</a>` | |
render(vdom2, document.body); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment