Published
Edited
Nov 29, 2018
Fork of Hello, HTM
Importers
Insert cell
Insert cell
Preact.render(htm`<${App} page="All" />`)
Insert cell
class App extends Preact.Component {
addTodo() {
const { todos = [] } = this.state;
this.setState({ todos: todos.concat(`Item ${todos.length}`) });
}
render({ page }, { todos = [] }) {
return htm`
<div class="app">
<${Header} name="ToDo's (${page})" />
<ul>
${todos.map(todo => html`
<li>${todo}</li>
`)}
</ul>
<button onClick=${() => this.addTodo()}>Add Todo</button>
<${Footer}>footer content here<//>
</div>
`;
}
}
Insert cell
Insert cell
Insert cell
htm = htmReq.bind(Preact.h)
Insert cell
htmReq = require("htm@1/dist/htm.js")
Insert cell
Preact = require("preact@8/dist/preact.min.js").catch(() => window.preact)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more