readme cleanup

This commit is contained in:
Micah Godbolt
2019-03-03 21:35:32 -08:00
parent a8f5965756
commit 6b69b0164c
33 changed files with 80 additions and 426 deletions

View File

@@ -6,7 +6,12 @@ import { Todos, FilterTypes } from './TodoApp.types';
let index = 0;
export class TodoApp extends React.Component<any, any> {
interface TodoAppState {
todos: Todos;
filter: FilterTypes;
}
export class TodoApp extends React.Component<any, TodoAppState> {
constructor(props) {
super(props);
this.state = {

View File

@@ -1,5 +1,7 @@
export type FilterTypes = 'all' | 'active' | 'completed';
export type CompleteTodo = (id) => null;
export interface TodoItem {
label: string;
completed: boolean;

View File

@@ -6,6 +6,7 @@ export class TodoList extends React.Component<any, any> {
render() {
const { filter, todos, complete } = this.props;
// filteredTodos returns an array of filtered todo keys [01,02,03]
const filteredTodos = Object.keys(todos).filter(id => {
return filter === 'all' || (filter === 'completed' && todos[id].completed) || (filter === 'active' && !todos[id].completed);
});