Last active
February 9, 2019 11:20
-
-
Save jeswin/fa33d73395ad66e2ee1187204ac4f521 to your computer and use it in GitHub Desktop.
router-article-todos
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 TodoList = ({ todos, pathArr }) => { | |
const [first, todoId] = pathArr; | |
return ( | |
<div> | |
<h1>Todos Module</h1> | |
{typeof todoId === "undefined" ? ( | |
<div> | |
<h2>List of todos:</h2> | |
{todos ? ( | |
todos.map(todo => <Todo key={todo.id} todo={todo} />) | |
) : ( | |
<p>There are no todos.</p> | |
)} | |
</div> | |
) : ( | |
<TodoDetail todo={todos.find(todo => todo.id == todoId)} /> | |
)} | |
</div> | |
); | |
}; | |
const Todo = ({ todo }) => ( | |
<p> | |
<a href="#" onClick={createClickHandler(`/todos/${todo.id}`)}> | |
{todo.text} | |
</a> | |
</p> | |
); | |
const TodoDetail = ({ todo }) => ( | |
<div> | |
Detail page for {todo.id} | |
<br /> | |
Text: {todo.text} | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment