Skip to content

Instantly share code, notes, and snippets.

@ryansolid

ryansolid/todos-app.jsx

Last active Aug 2, 2019
Embed
What would you like to do?
Todos: TodoApp
const TodoApp = () => {
const [store, {
addTodo, toggleAll, editTodo,
removeTodo, clearCompleted, setVisibility
}] = createTodosStore(),
locationHandler = () =>
setVisibility(location.hash.slice(2) || 'all'
);
window.addEventListener('hashchange', locationHandler);
onCleanup(() =>
window.removeEventListener('hashchange', locationHandler)
);
return <section class='todoapp'>
<TodoHeader addTodo={addTodo} />
<Show when={(store.todos.length > 0)}>
<TodoList {...{store, toggleAll, editTodo, removeTodo}}/>
<TodoFooter store={store} clearCompleted={clearCompleted} />
</Show>
</section>
}
createRoot(() => document.body.insertBefore(
<TodoApp />,
document.body.firstChild
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.