-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathTodos.js
More file actions
61 lines (50 loc) · 1.2 KB
/
Todos.js
File metadata and controls
61 lines (50 loc) · 1.2 KB
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
import React from "react";
import Todo from "../components/Todo";
import NewTodo from "../components/NewTodo";
import * as TodoActions from "../actions/TodoActions";
import TodoStore from "../stores/TodoStore";
export default class Todos extends React.Component {
constructor() {
super();
this.getTodos = this.getTodos.bind(this);
this.state = {
todos: TodoStore.getAll()
};
}
componentWillMount() {
TodoStore.on("change", this.getTodos);
}
componentWillUnmount() {
TodoStore.removeListener("change", this.getTodos);
}
getTodos() {
this.setState({
todos: TodoStore.getAll(),
});
}
reloadTodos() {
TodoActions.reloadTodos();
}
render() {
const { todos } = this.state;
const TodoComponents = todos.map((todo) => {
return <Todo key={todo.id} {...todo}/>;
});
const customUl = {
listStyle: "none",
paddingLeft: "0"
};
const headerStyling = {
fontFamily: "Roboto",
color: "#3C1053",
marginBottom: "20px"
};
return (
<div>
<h1 style={headerStyling}>A List of things To Do</h1>
<NewTodo />
<ul style={customUl}>{TodoComponents}</ul>
</div>
);
}
}