Skip to content

Commit

Permalink
refactor(examples): update hdom-basics
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 29, 2018
1 parent 7fdf172 commit b86d5b2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions examples/hdom-basics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import { start } from "@thi.ng/hdom";
// (not used here, see `hdom-context-basics` example for details)
const greeter = (_, name) => ["h1.title", "hello ", name];

// component w/ local state
// counter component w/ local state
const counter = (i = 0) => {
return () => ["button", { onclick: () => (i++) }, `clicks: ${i}`];
const attribs = { onclick: () => (i++) };
return () => ["button", attribs, `clicks: ${i}`];
};

const app = () => {
// initialization steps
// ...
// root component is just a static array
return ["div#app", [greeter, "world"], counter(), counter(100)];
};
// root component is a simple array
const app = ["div#app", [greeter, "world"], counter(), counter(100)];

start(document.body, app());
start(document.body, app);

0 comments on commit b86d5b2

Please sign in to comment.