Created
February 3, 2018 11:44
-
-
Save franciscotln/7f123909a5acd804bc202d06b1c7c2f3 to your computer and use it in GitHub Desktop.
separated view in react
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
const AppView = props => | |
<div className='App'> | |
<PeopleList {...props.state} onDelete={props.deletePerson} /> | |
</div>; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
people: [ | |
{ id: 1, name: 'Person A' }, | |
{ id: 2, name: 'Person B' }, | |
{ id: 3, name: 'Person C' }, | |
{ id: 4, name: 'Person D' }, | |
], | |
}; | |
} | |
deletePerson = id => { | |
this.setState(evolve({ | |
people: reject(whereEq({ id })) | |
})); | |
}; | |
render() { | |
return <AppView {...this} />; | |
} | |
} | |
export { App }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment