Last active
November 11, 2017 19:05
-
-
Save eddyw/4694a588cb2e5f0cdfd412cb9b69c440 to your computer and use it in GitHub Desktop.
Map Component
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
const Item = ({ title, completed, check, style, className }) => ( | |
<li className={className}> | |
<span>{check} ({String(completed)}) </span> | |
<span style={style}>{title}</span> | |
</li> | |
) | |
const map = item => ({ | |
...item, | |
check: item.completed? 'o' : 'x', | |
style: item.completed? { color: 'gree' } : { color: 'red' }, | |
}) | |
const TodoList = () => ( | |
<ul> | |
<MapArray from={todoList} map={map}> | |
<Item className="todo__item" /> | |
</MapArray> | |
</ul> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment