mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Moved todos to state
This commit is contained in:
@@ -4,18 +4,21 @@ import { TodoHeader } from './components/TodoHeader';
|
||||
import { TodoList } from './components/TodoList';
|
||||
|
||||
|
||||
export class TodoApp extends React.Component {
|
||||
export class TodoApp extends React.Component<any, any> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
todos: [
|
||||
{key: 1, text: 'Todo 1', completed: true},
|
||||
{key: 2, text: 'Todo 2'},
|
||||
{key: 3, text: 'Todo 3'},
|
||||
{key: 4, text: 'Todo 4'},
|
||||
],
|
||||
filter: 'all'
|
||||
}
|
||||
}
|
||||
render() {
|
||||
|
||||
const todos = [
|
||||
{key: 1, text: 'Todo 1', completed: true},
|
||||
{key: 2, text: 'Todo 2'},
|
||||
{key: 3, text: 'Todo 3'},
|
||||
{key: 4, text: 'Todo 4'},
|
||||
];
|
||||
|
||||
const filter = 'all';
|
||||
|
||||
const {filter, todos} = this.state;
|
||||
return (
|
||||
<div>
|
||||
<TodoHeader filter={filter} />
|
||||
|
||||
Reference in New Issue
Block a user