Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. const TodoApp = () => {
  2. const [store, {
  3. addTodo, toggleAll, editTodo,
  4. removeTodo, clearCompleted, setVisibility
  5. }] = createTodosStore(),
  6. locationHandler = () =>
  7. setVisibility(location.hash.slice(2) || 'all'
  8. );
  9.  
  10. window.addEventListener('hashchange', locationHandler);
  11. onCleanup(() =>
  12. window.removeEventListener('hashchange', locationHandler)
  13. );
  14. return <section class='todoapp'>
  15. <TodoHeader addTodo={addTodo} />
  16. <$ when={store.todos.length > 0}>
  17. <TodoList {...{store, toggleAll, editTodo, removeTodo}}/>
  18. <TodoFooter store={store} clearCompleted={clearCompleted} />
  19. </$>
  20. </section>
  21. }
  22.  
  23. createRoot(() => document.body.insertBefore(
  24. <TodoApp />,
  25. document.body.firstChild
  26. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement