From c4fd1821d7ecbc34e93c835ce4e06cfd8453f8d4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Maeda Date: Wed, 27 Jul 2022 15:34:56 +0900 Subject: [PATCH] Impl display todos with useAppSelector and TodoList component. --- .../todos/components/TodoContainer.tsx | 3 + src/features/todos/components/TodoList.tsx | 69 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/features/todos/components/TodoList.tsx diff --git a/src/features/todos/components/TodoContainer.tsx b/src/features/todos/components/TodoContainer.tsx index 2b21a7d..226d96e 100644 --- a/src/features/todos/components/TodoContainer.tsx +++ b/src/features/todos/components/TodoContainer.tsx @@ -1,10 +1,13 @@ import type { FC } from 'react'; import { TodoForm } from './TodoForm'; +import { TodoList } from './TodoList'; export const TodoContainer: FC = () => { return (
+
+
); }; diff --git a/src/features/todos/components/TodoList.tsx b/src/features/todos/components/TodoList.tsx new file mode 100644 index 0000000..1bf20ed --- /dev/null +++ b/src/features/todos/components/TodoList.tsx @@ -0,0 +1,69 @@ +import type { FC } from 'react'; +import { useAppSelector } from '../../../app/hooks'; + +export const TodoList: FC = () => { + const todos = useAppSelector((state) => state.todos.todos); + + return ( + <> + + + + + + + + + + + + + + + + {todos.length === 0 ? ( + + + + ) : ( + todos.map((todo) => { + return ( + + + + + + + + + + + + ); + }) + )} + +
idタイトル本文ステータス作成日時更新日時削除日時更新ボタン削除ボタン
+ データなし +
{todo.id}{todo.title}{todo.body}{todo.status}{todo.createdAt}{todo.updatedAt ?? '無し'}{todo.deletedAt ?? '無し'} + + + +
+ + ); +}; + +export default TodoList;