function Component({ showMessage }) {
h('div', () => {
h('h1', {
text: 'Hey there',
visible: showMessage
})
})
}
I don't think it is better than the current React API `r = React.createElement` const Component = ({ showMessage }) =>
r('div', null,
showMessage && r('h1', null, 'Hey there'))
export default function(render) {
const $page = createElement(`
whatever here
`);
render($page);
$page.addEventListener("xxxx");
onDestroy(/* remove listeners */);
}
Yes I sort of had to write my own mini framework but it's well under 100 lines of codes [0] with the idea that maintaining that 100 lines of codes is gonna be a massive win compared to keeping up with any "modern framework" npm hellThe core idea is that instead of trying to pretend some cool ideas like HOC or render props, we call a dog a dog and say "decorator pattern" and just use the pattern directly [3] and when we need to compose things we do so as well [4]
ref:
- [0] the skeleton I started to settle on a nice API before starting the full rewrite https://mickael-kerjean.github.io/skeleton/example/index.htm...
- [1] original oss project which I'm migrating: https://github.com/mickael-kerjean/filestash
- [2] current state of the rewrite where you can see this pattern in action https://github.com/mickael-kerjean/filestash-rewrite/tree/ma...
- [3] https://github.com/mickael-kerjean/filestash-rewrite/blob/ma...
- [4] https://github.com/mickael-kerjean/filestash-rewrite/blob/ma...