// @flow import React, { PureComponent } from 'react'; import TodoEditInput from './todo-edit-input'; import TodoListItem from './todo-list-item'; import type { TodoType } from '../types/todo'; type Props = { todos: Array, deleteTodo: Function, toggleEdit: Function, updateTodo: Function, cancelUpdateTodo: Function, }; export default class TodoList extends PureComponent { renderTodoView = (todo: TodoType) => { const { deleteTodo, toggleEdit } = this.props; return ; }; renderEditView = (todo: TodoType) => { const { updateTodo, cancelUpdateTodo } = this.props; return ; }; renderList = () => { const { todos } = this.props; const sortTodosByTime = todos.sort((a, b) => b.createdAt - a.createdAt); return (
    {sortTodosByTime.map(todo => (
  • {todo.editing ? this.renderEditView(todo) : this.renderTodoView(todo)}
  • ))}
); }; renderEmptyState = () =>

No todos right now

; render() { const { todos } = this.props; const hasTodos = todos.length; return hasTodos ? this.renderList() : this.renderEmptyState(); } }