-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (25 loc) · 688 Bytes
/
app.js
File metadata and controls
28 lines (25 loc) · 688 Bytes
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
import React from 'react';
import TodoList from './todo_list.js';
import TodoInput from './todo_input.js';
var todos = [
{ id: "todo1", done: true, description: "以做完"},
{ id: "todo2", done: false, description: "未做完"},
{ id: "todo3", done: false, description: "卡住了"}
]
var App = React.createClass({
// 初始化 State值
getInitialState(){
return { todos: todos }
},
handleAddTodo(todo){
this.setState({ todos: this.state.todos.concat(todo) })
},
render(){
return <div>
<h3>Hello todos!!!</h3>
<TodoList todos={this.state.todos}/>
<TodoInput handleAddTodo={ this.handleAddTodo }/>
</div>
}
})
module.exports = App