Skip to content

Instantly share code, notes, and snippets.

@franciscotln
Created February 3, 2018 00:13
Show Gist options
  • Save franciscotln/5b82f8ec903dad13309793a0c6596990 to your computer and use it in GitHub Desktop.
Save franciscotln/5b82f8ec903dad13309793a0c6596990 to your computer and use it in GitHub Desktop.
react 16
import React from 'react';
const ListWrapper = ({ children }) => (
<div className='people-list-wrapper'>
<ul className='people-list'>
{children}
</ul>
</div>
);
const PersonName = ({ text }) => <span className='person-name'>{text}</span>;
const DeleteButton = ({ text, handler }) => <span className='delete-button' onClick={handler}>{text}</span>;
const PersonRow = ({ children }) => <li className='person-row'>{children}</li>
const People = ({ people, onDelete }) => people.map(({ id, name }) => (
<PersonRow key={id}>
<PersonName text={name} />
<DeleteButton text='X' handler={() => onDelete(id)} />
</PersonRow>
));
const PeopleList = props => (
<ListWrapper>
<People {...props} />
</ListWrapper>
);
export { PeopleList };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment