Created
March 28, 2021 13:55
-
-
Save mt-inside/5714e609232fe8edcc80de14b096c919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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