Skip to content

Instantly share code, notes, and snippets.

@franciscotln
Created February 3, 2018 11:44
Show Gist options
  • Save franciscotln/7f123909a5acd804bc202d06b1c7c2f3 to your computer and use it in GitHub Desktop.
Save franciscotln/7f123909a5acd804bc202d06b1c7c2f3 to your computer and use it in GitHub Desktop.
separated view in react
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