Last active
October 7, 2018 19:09
-
-
Save NetanelBasal/96087e4c650c1dff66145f2d45ad1462 to your computer and use it in GitHub Desktop.
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
export class AddTodo extends React.PureComponent { | |
render() { | |
return (...); | |
} | |
} |
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
export class Filters extends React.PureComponent { | |
render() { | |
return ( | |
<div> | |
<span>Show: </span> | |
<select onChange={this.props.onChange} value={this.props.active}> | |
<option value="SHOW_ALL">All</option> | |
<option value="SHOW_ACTIVE">Active</option> | |
<option value="SHOW_COMPLETED">Completed</option> | |
</select> | |
</div> | |
); | |
} | |
} |
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
export class Todo extends React.PureComponent { | |
onClick = () => this.props.toggleTodo(this.props.id); | |
onDelete = () => this.props.onDelete(this.props.id); | |
render() { | |
return ( | |
<li> | |
<span onClick={this.toggleTodo}> | |
{this.props.text} | |
</span> | |
<button onClick={this.onDelete}>Delete</button> | |
</li> | |
); | |
} | |
} | |
export class TodoList extends React.PureComponent { | |
toggleTodo = id => this.props.toggleTodo(id); | |
onDelete = id => this.props.onDelete(id); | |
render() { | |
return ( | |
<ul> | |
{this.props.todos.map(todo => ( | |
<Todo | |
key={todo.id} | |
{...todo} | |
toggleTodo={this.toggleTodo} | |
onDelete={this.onDelete} | |
/> | |
))} | |
</ul> | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment