Skip to content

Instantly share code, notes, and snippets.

@cevr
Created June 8, 2019 21:53
Show Gist options
  • Save cevr/a6d514bee8f8cebbb7e82ab053d28a61 to your computer and use it in GitHub Desktop.
Save cevr/a6d514bee8f8cebbb7e82ab053d28a61 to your computer and use it in GitHub Desktop.
function Todos() {
const todos = useStore(state => state.todos);
const { toggle, del } = useActions(actions => ({
toggle: actions.toggle,
del: actions.delete,
}));
const todosList = Object.values(todos);
return todosList.map(todo => (
<Todo key={todo.id} todo={todo} toggle={toggle} del={del} />
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment