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';
|
import { TodoList } from './components/TodoList';
|
||||||
|
|
||||||
|
|
||||||
export class TodoApp extends React.Component {
|
export class TodoApp extends React.Component<any, any> {
|
||||||
render() {
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
const todos = [
|
this.state = {
|
||||||
|
todos: [
|
||||||
{key: 1, text: 'Todo 1', completed: true},
|
{key: 1, text: 'Todo 1', completed: true},
|
||||||
{key: 2, text: 'Todo 2'},
|
{key: 2, text: 'Todo 2'},
|
||||||
{key: 3, text: 'Todo 3'},
|
{key: 3, text: 'Todo 3'},
|
||||||
{key: 4, text: 'Todo 4'},
|
{key: 4, text: 'Todo 4'},
|
||||||
];
|
],
|
||||||
|
filter: 'all'
|
||||||
const filter = 'all';
|
}
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
const {filter, todos} = this.state;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<TodoHeader filter={filter} />
|
<TodoHeader filter={filter} />
|
||||||
|
|||||||
Reference in New Issue
Block a user