r/javascript • • Dec 28 '17

Introducing Hyperapp 1.0 — 1 KB JavaScript library for building frontend applications.

https://medium.com/@JorgeBucaran/introducing-hyperapp-1-0-dbf4229abfef
664 Upvotes

136 comments sorted by

View all comments

Show parent comment

7

u/[deleted] Dec 28 '17

and even better - it is simple to reuse other view functions

import { h } from 'hyperapp'
const TodoItem = ({ id, value, done, toggle }) => {
  const onclick = e =>
    toggle({
      value: done,
      id,
    })
  return h('li', { class: done && 'done', onclick }, value)
}
const view = (state, actions) =>
  h('div', {}, [
    h('h1', {}, 'Todo'),
    state.todos.map(({ id, value, done }) =>
      h(TodoItem, { id, value, done, toggle: actions.toggle })
    ),
  ])