From ae89b3320a6a536edbbf5efa12715843eb70a738 Mon Sep 17 00:00:00 2001 From: Micah Godbolt Date: Tue, 12 Feb 2019 15:52:32 -0800 Subject: [PATCH] Moved todos to state --- step06/src/App.tsx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/step06/src/App.tsx b/step06/src/App.tsx index d6265ff..d14f9b5 100644 --- a/step06/src/App.tsx +++ b/step06/src/App.tsx @@ -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 { + 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 (