Skip to content

Instantly share code, notes, and snippets.

@MrHus
Created June 8, 2017 08:01
Show Gist options
  • Save MrHus/2dd8b9382ded91dfa90087bfeb6102f5 to your computer and use it in GitHub Desktop.
Save MrHus/2dd8b9382ded91dfa90087bfeb6102f5 to your computer and use it in GitHub Desktop.
The PersonDetail Component
// @flow
import React, { Component } from 'react';
import DeleteButton from './DeleteButton';
type Person = {
id: number,
name: string,
age: number
};
type Props = {
person: Person
};
export default class PersonDetail extends Component<void, Props, void> {
onDelete(person: Person) {
console.log(`Deleting person with id: ${ person.id }`);
}
render() {
const { person } = this.props;
return (
<div class="panel">
<h1>{ person.name }</h1>
<h2>{ person.age }</h2>
<DeleteButton onClick={ () => this.onDelete(person) } />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment