Published
Edited
Dec 21, 2018
2 forks
31 stars
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 => htm`
<li>${todo}</li>
`)}
</ul>
<button onClick=${() => this.addTodo()}>Add Todo</button>
<${Footer}>footer content here</>
</div>
`;
}
}
Insert cell
Insert cell
Insert cell
htm = (await require("htm@2/dist/htm.umd.js")).bind(Preact.h)
Insert cell
Preact = require("preact@8/dist/preact.min.js").catch(() => window.preact)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more