Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

bun.lockb

# Dependencies
node_modules
.yarn/*
Expand Down
44 changes: 15 additions & 29 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
import { createElement, useState } from "react"
import htm from "htm"

const html = htm.bind(createElement)

function App() {
const [count, setCount] = useState(0)

return createElement(
"div",
{ className: "App" },
createElement(
"a",
{ href: "https://react.dev/", target: "_blank" },
createElement("img", {
src: "/react.svg",
className: "logo",
alt: "React logo",
}),
),
createElement("h1", {}, "React"),
createElement(
"div",
{ className: "card" },
createElement(
"button",
{ onClick: () => setCount((count) => count + 1) },
"count is ",
count,
),
),
createElement(
"p",
{ className: "read-the-docs" },
"Click on the React logo to learn more",
),
)
return html`<div className="App">
<a href="https://react.dev/" target="_blank">
<img src="/react.svg" className="logo" alt="React logo" />
</a>
<h1>React but with HTM</h1>
<div className="card">
<button onClick=${() => setCount((count) => count + 1)}>
count is ${count}
</button>
</div>
<p className="read-the-docs">Click on the React logo to learn more</p>
</div>`
}

export default App
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"react": "https://esm.sh/react",
"react/": "https://esm.sh/react/",
"react-dom": "https://esm.sh/react-dom",
"react-dom/": "https://esm.sh/react-dom/"
"react-dom/": "https://esm.sh/react-dom/",
"htm": "https://esm.sh/htm"
}
}
</script>
Expand Down