Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created February 18, 2019 12:57
Show Gist options
  • Save amandeepmittal/158ff3cb67bd5acf2994d102032bafc5 to your computer and use it in GitHub Desktop.
Save amandeepmittal/158ff3cb67bd5acf2994d102032bafc5 to your computer and use it in GitHub Desktop.
checkTodo = id => {
setTodos(
todos.map(todo => {
if (todo.key === id) todo.checked = !todo.checked;
return todo;
})
);
};
deleteTodo = id => {
setTodos(
todos.filter(todo => {
if (todo.key !== id) return true;
})
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment