Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Preact standalone module test
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="module">
import {html, render, useState} from '';
const Counter = () => {
const [count, setCount] = useState(0)
const increment = () => setCount(count + 1)
const decrement = () => {
if (count > 0) setCount((currentCount) => currentCount - 1)
return html`
Count: ${count}
<button onClick=${decrement}>-</button>
<button onClick=${increment}>+</button>
render(html`<${Counter}/>`, document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment