Skip to content

Instantly share code, notes, and snippets.

@oampo
Created October 3, 2017 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oampo/44e46c65f4fc5ec10c3e96082e92ab20 to your computer and use it in GitHub Desktop.
Save oampo/44e46c65f4fc5ec10c3e96082e92ab20 to your computer and use it in GitHub Desktop.
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>;
}
}
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