Last active
February 18, 2022 04:02
-
-
Save brandonros/8850a4aad95f53c00375194d9cb35585 to your computer and use it in GitHub Desktop.
Preact + htm template strings example (no JSX, no transpiling, unpkg imports)
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> | |
</head> | |
<body> | |
<script type="module"> | |
import * as Preact from 'https://unpkg.com/[email protected]/dist/preact.module.js' | |
import htm from 'https://unpkg.com/[email protected]/dist/htm.module.js' | |
const html = htm.bind(Preact.createElement) | |
class App extends Preact.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return html` | |
<div>Hello, world!</div> | |
` | |
} | |
} | |
window.addEventListener('load', () => { | |
Preact.render(html`<${App}/>`, document.body) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment