Created
October 3, 2017 15:35
-
-
Save oampo/44e46c65f4fc5ec10c3e96082e92ab20 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
import React from 'react'; | |
import Person from './person'; | |
export default class PersonList extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
people: [ | |
{ | |
id: 0, | |
name: 'Adam Smith', | |
number: '01234 567890' | |
}, | |
{ | |
id: 1, | |
name: 'Chris Klanac', | |
number: '01234 567896' | |
}, | |
{ | |
id: 2, | |
name: 'Rich Greenhill', | |
number: '01234 567875' | |
} | |
] | |
}; | |
} | |
render() { | |
const people = this.state.people.map(person => ( | |
<Person key={person.id} name={person.name} number={person.number} /> | |
)); | |
return <div className="person-list">{people}</div>; | |
} | |
} |
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
import React from 'react'; | |
export default function Person(props) { | |
return ( | |
<div className="person"> | |
<div className="person-name">{props.name}</div> | |
<div className="person-number">{props.number}</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment