Created
February 3, 2018 00:13
-
-
Save franciscotln/5b82f8ec903dad13309793a0c6596990 to your computer and use it in GitHub Desktop.
react 16
This file contains 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'; | |
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