Skip to content

Instantly share code, notes, and snippets.

@markbrown4
Created September 1, 2016 21:34
Show Gist options
  • Save markbrown4/31836333e9ac1a6d256abaf860cc010b to your computer and use it in GitHub Desktop.
Save markbrown4/31836333e9ac1a6d256abaf860cc010b to your computer and use it in GitHub Desktop.
const Todo = (props, send)=> {
const todo = props.todo
const index = props.index
return html`
<li>
<input
type="checkbox"
${todo.completed ? 'checked' : ''}
onchange=${(e)=> onChange(e, index)}
/>
${todo.title}
</li>
`
function onChange(e, index) {
const updates = { completed: e.target.checked }
send('updateTodo', { index: index, updates: updates })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment