Last active
April 15, 2019 20:15
-
-
Save benkissi/adb2eaf73d6b40bf4a4c750b32990049 to your computer and use it in GitHub Desktop.
Context blog
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
const DisplayTodos = props => { | |
return ( | |
<AppConsumer> | |
{({ todos, completed }) => { | |
const notCompleted = todos.filter(todo => { | |
if (todo.completed === false) { | |
return todo; | |
} | |
}); | |
return ( | |
<div> | |
<p>All your todos: {notCompleted.length}</p> | |
<ol> | |
{todos.length > 0 | |
? todos.map(todo => ( | |
<li | |
className={ | |
todo.completed | |
? "completed todo align-left" | |
: "todo align-left" | |
} | |
key={todo.id} | |
onClick={() => completed(todo.id)} | |
> | |
{todo.todo} | |
{" "} | |
<span className={todo.completed ? "date" : "date"}> | |
{new Date(todo.createdAt).toString()} | |
</span> | |
</li> | |
)) | |
: ""} | |
</ol> | |
</div> | |
); | |
}} | |
</AppConsumer> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment