Skip to content

Instantly share code, notes, and snippets.

@jeswin
Last active February 9, 2019 11:20
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 jeswin/fa33d73395ad66e2ee1187204ac4f521 to your computer and use it in GitHub Desktop.
Save jeswin/fa33d73395ad66e2ee1187204ac4f521 to your computer and use it in GitHub Desktop.
router-article-todos
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