Look Ma, no tricky hooks, nice.
import { m, mount} from "umai";
let counters = [];
const Count = ({ initialCount }) => {
let count = initialCount || 0;
let inc = () => { count += 1 };
return () => (
<div>
<h1>Count: {count}</h1>
<button class="button" onclick={inc}>increment</button>
</div>
);
};
const App = () => <div>
{counters.map(m)}
</div>;
mount(document.body, App);
counters.push(Count);
counters.push(Count({initialCount:1}))
counters.push(Count({initialCount:2}))
counters.push(Count({initialCount:3}))
Top comments (0)