Last active
July 7, 2019 04:09
-
-
Save JeromeFranco/184cb070571212f939fd7694eeb888e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class TodosPage extends React.Component { | |
state = { | |
todos: [ | |
{ id: 1, desc: 'Check email', completed: false }, | |
{ id: 2, desc: 'Write blog post', completed: false }, | |
], | |
user: { name: 'John', canDelete: true }, | |
}; | |
handleDelete = todo => { | |
const todos = this.state.todos.filter(t => t.id !== todo.id); | |
this.setState({ todos }); | |
}; | |
render() { | |
const { todos, user } = this.state; | |
return ( | |
<div> | |
<TodoList | |
todos={todos} | |
onDelete={this.handleDelete} | |
canDelete={user.canDelete} | |
/> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment