Skip to content

Instantly share code, notes, and snippets.

@eddyw
Last active November 11, 2017 19:05
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 eddyw/4694a588cb2e5f0cdfd412cb9b69c440 to your computer and use it in GitHub Desktop.
Save eddyw/4694a588cb2e5f0cdfd412cb9b69c440 to your computer and use it in GitHub Desktop.
Map Component
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