Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// props that will be used for ContactList component.
interface IContactListProps {
contacts: IContact[]
}
// ContactList component
class ContactList extends React.Component<IContactListProps, any> {
// create <li><p></p></li> for each contact
renderContacts() {
return this.props.contacts.map(contact => {
return <li><p>{contact.firstName} {contact.lastName}</p></li>
});
}
// render the contacts
render () {
return <ul>
{this.renderContacts()}
</ul>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment