Skip to content

Instantly share code, notes, and snippets.

@eddyw
Last active November 11, 2017 17:02
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/f0054305d8ca59249ee34bf573a8cdab to your computer and use it in GitHub Desktop.
Save eddyw/f0054305d8ca59249ee34bf573a8cdab to your computer and use it in GitHub Desktop.
Map Component
const completedStyle = { color: 'green' }
const uncompletedStyle = { color: 'red' }
const Item = ({ title, completed }) => (
<li>
<span>{completed ? 'o' : 'x'} </span>
<span style={completed ? completedStyle : uncompletedStyle}>{title}</span>
</li>
)
const TodoList = () => (
<ul>
{todoList.map((item, key) => (
<Item key={key} {...item} />
))}
</ul>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment