Skip to content

Instantly share code, notes, and snippets.

@csorlandi
Last active August 29, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csorlandi/b6a021f674dc42cc7cdf1124bf184c38 to your computer and use it in GitHub Desktop.
Save csorlandi/b6a021f674dc42cc7cdf1124bf184c38 to your computer and use it in GitHub Desktop.
function handleTaskSelected(id) {
setTodoList(
todoList.map(todo => ({
...todo,
checked: todo.id === id ? !todo.checked : todo.checked,
})
);
}
<input type="checkbox" onChange={() => handleTaskSelected(todo.id)} className={`${todo.checked && 'checked'}`} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment