forked from prescottprue/react-redux-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTodoItem.js
34 lines (30 loc) · 832 Bytes
/
TodoItem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { firebaseConnect } from 'react-redux-firebase'
import './Todo.css'
@firebaseConnect()
export default class TodoItem extends Component {
static propTypes = {
todo: PropTypes.object,
id: PropTypes.string
}
render(){
const { firebase, todo, id } = this.props
const toggleDone = () => firebase.set(`/todos/${id}/done`, !todo.done)
const deleteTodo = (event) => firebase.remove(`/todos/${id}`)
return (
<li className="Todo">
<input
className="Todo-Input"
type="checkbox"
checked={todo.done}
onChange={toggleDone}
/>
{todo.text}
<button className="Todo-Button" onClick={deleteTodo}>
Delete
</button>
</li>
)
}
}