From f5eaf9e52506a5f9ce734a89c8ff9dbf32e7e5d0 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Tue, 16 Jun 2020 17:48:18 +0300 Subject: [PATCH] do not render nonexistent todo --- client/src/components/Todos/Todos.js | 64 +++++++++++++++------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/client/src/components/Todos/Todos.js b/client/src/components/Todos/Todos.js index 82c845e..41bb551 100644 --- a/client/src/components/Todos/Todos.js +++ b/client/src/components/Todos/Todos.js @@ -49,35 +49,41 @@ const Todos = ({ data }) => { <> - {data.map((todo, i) => - - - - - {todo.category.title} - - - {new Date(todo.deadline).toLocaleString()} - - - - {todo.title} - - - {todo.description} - - - - handleOpenModal(todo)} aria-label="update"> - - - handleOpenDialog(todo)} aria-label="delete" color='secondary'> - - - - - - )} + {data.map((todo, i) => { + if (todo.category) { + return ( + + + + + {todo.category.title} + + + {new Date(todo.deadline).toLocaleString()} + + + + {todo.title} + + + {todo.description} + + + + handleOpenModal(todo)} aria-label="update"> + + + handleOpenDialog(todo)} aria-label="delete" color='secondary'> + + + + + + ) + } else { + return null + } + })} ) }