Created
June 8, 2017 08:01
-
-
Save MrHus/2dd8b9382ded91dfa90087bfeb6102f5 to your computer and use it in GitHub Desktop.
The PersonDetail Component
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
| // @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