-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anil Vemula
authored and
Anil Vemula
committed
Apr 2, 2019
1 parent
82828fd
commit 6e77af4
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from "prop-types"; | ||
|
||
|
||
export class TodoItem extends Component { | ||
getStyle=() =>{ | ||
return{ | ||
background: '#f4f4f4', | ||
padding: '10px', | ||
borderBottom: '1px #ccc dotted', | ||
textDecoration: this.props.todo.completed ? 'line-through' : 'none' | ||
} | ||
} | ||
|
||
markComplete=(e)=>{ | ||
console.log(this.props) | ||
} | ||
render() { | ||
const {id, title} = this.props.todo; | ||
return ( | ||
<div style={this.getStyle()}> | ||
<p> | ||
<input type="checkbox" onChange={this.props.markComplete.bind(this, id)}/>{' '} | ||
{title} | ||
</p> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
//prop types | ||
|
||
TodoItem.propTypes={ | ||
todo:PropTypes.object.isRequired | ||
} | ||
|
||
export default TodoItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { Component } from 'react'; | ||
import TodoItem from "./TodoItem"; | ||
import PropTypes from "prop-types"; | ||
|
||
class Todos extends Component { | ||
|
||
render() { | ||
console.log(this.props.todos) | ||
return this.props.todos.map((todo)=>( | ||
<TodoItem key={todo.id} todo={todo} markComplete={this.props.markComplete}/> | ||
) | ||
); | ||
} | ||
} | ||
|
||
//prop types | ||
Todos.propTypes={ | ||
todos:PropTypes.array.isRequired | ||
} | ||
|
||
export default Todos; |