Skip to content

Instantly share code, notes, and snippets.

@mt-inside
Created March 28, 2021 13:55
Show Gist options
  • Save mt-inside/5714e609232fe8edcc80de14b096c919 to your computer and use it in GitHub Desktop.
Save mt-inside/5714e609232fe8edcc80de14b096c919 to your computer and use it in GitHub Desktop.
import { app } from 'hyperapp';
import h from 'hyperapp-jsx-pragma';
const AddTodo = (state) => ({
...state,
value: "",
todos: state.todos.concat(state.value),
})
const NewValue = (state, event) => ({
...state,
value: event.target.value,
})
function viewFn(state) {
console.log(state);
return <main>
<h1>To do list</h1>
<input type="text" onInput={[NewValue, state.value]} />
<ul>
</ul>
<button onClick={AddTodo}>New!</button>
</main>
}
app({
init: { todos: [], value: "" },
view: viewFn,
node: document.getElementById("app"),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment