import * as React from "react"; import { TodoData } from "./TodoData"; import { TodoItem } from "./TodoItem"; import { Filter, FilterState } from "./Filter"; type Props = { items: TodoData[]; onCheck: (item: TodoData, checked: boolean) => void; }; export const TodoList = ({ items, onCheck }: Props) => { const [state, setState] = React.useState("All"); const displayItems = items.filter((item) => { if (state === "All") return true; if (state === "Done" && item.done) return true; if (state === "Todo" && !item.done) return true; return false; }); return ( <> setState(key)} /> {displayItems.map((item) => ( ))}
{displayItems.length} items
); };