|
|
|
|
|
by kevlened
219 days ago
|
|
Your example template and the others here are almost jsx after it's compiled (handwritten below). This jsx discussion seems more about removing the compile step, which you can do with https://github.com/developit/htm import { createElement as m } from "your-jsx-compatible-library";
var ListComponent = () => {
let count = 0, selected = null;
return {
view: ({ attrs: { items }}) =>
m("div", null,
m("p", null, "Clicked: " + count + " times"),
m("ul", null, items.map((item) =>
m("li", {
onclick: () => { count++; selected = item; },
style: { cursor: "pointer", color: item === selected ? "blue" : "black" },
}, item)
)),
selected && m("p", null, "Selected: " + selected)
)
};
};
|
|