-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathindex.jsx
65 lines (59 loc) · 1.58 KB
/
index.jsx
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react';
export default class TodoBox extends React.Component {
render() {
return (
<div className="todoBox">
<h1>Todos</h1>
<TodoList />
<TodoForm />
</div>
);
}
}
class TodoList extends React.Component {
render() {
return (
<div className="todoList">
<table style={{border: "2px solid black"}}>
<tbody>
<Todo title="Shopping">Milk</Todo>
<Todo title="Hair cut">13:00</Todo>
<Todo title="Learn React">15:00</Todo>
</tbody>
</table>
</div>
);
}
}
class Todo extends React.Component {
constructor(props) {
super(props);
this.state = {checked: false};
}
handleChange(e) {
this.setState({checked: e.target.checked});
}
render() {
return (
<tr>
<td style={{border: "1px solid black"}}>
<input type="checkbox" checked={this.state.checked} onChange={this.handleChange}/>
</td>
<td style={{border: "1px solid black"}}>{this.props.title}</td>
<td style={{border: "1px solid black"}}>{this.props.children}</td>
</tr>
);
}
}
Todo.propTypes = {
title: React.PropTypes.string.isRequired
};
class TodoForm extends React.Component {
render() {
return (
<div className="todoForm">
I am a TodoForm.
</div>
);
}
}