A simple react todo application
git clone ...
cd react-todo
npm install
atom .
npm start
- create initial state
{
todos: [{
id: 1,
title: 'Pick Final Project',
completed: false
}, {
id: 2,
title: 'Plan Final Project',
completed: false
}]
}
- render state using map
Included is a module fun-fp you can use the map function from fun-fp or you can use the array map function, but the goal is to map over the todos and display them using the
TodoItem
component
- create controlled input and submit form
- append new item to state
- create onToggle function
- pass to todo-item as prop
- if the item is completed add
completed to the classname
-
TodoItem needs its own state editText: this.props.todo.title
-
TodoItem needs to handle the following events
- handleEdit
- handleChange
- handleSubmit
-
View Label should listen for double click event
- onDoubleClick = this.handleEdit
-
Edit Input should be controlled
- value = this.state.editText
- onChange = this.state.handleChange
- onBlur = this.state.handleSubmit
-
Implement editText, handleChange, handleSubmit on TodoItem Component
-
Render method should change li className to editing if this.props.editing is not null
-
App should pass the following props to TodoItem
- editing = this.state.editing
- onEdit = this.editTodo(todo)
- onSave = this.saveTodo(todo)
-
Implement editTodo and saveTodo on app component
- When the delete button is clicked we want to tell the app state to remove the item
- reduce over todos and inc completed = false
- toggle viewState = 'active'
- on render filter todos based on viewState
- handle completed click and filter todos and assign filtered list