MCPcopy Index your code
hub / github.com/UI5/sample-webcomponents-react / TodoList

Function TodoList

src/components/TodoList.tsx:8–37  ·  view source on GitHub ↗
({
	items,
	handleSelectionChange,
	handleDelete,
	handleEdit,
}: {
	items: TodoItemType[];
	handleSelectionChange: (event: CustomEvent<ListSelectionChangeEventDetail>) => void;
	handleDelete: (id: number) => void;
	handleEdit: (id: number) => void;
})

Source from the content-addressed store, hash-verified

6import { TodoItem as TodoItemType } from "../types";
7
8function TodoList({
9 items,
10 handleSelectionChange,
11 handleDelete,
12 handleEdit,
13}: {
14 items: TodoItemType[];
15 handleSelectionChange: (event: CustomEvent<ListSelectionChangeEventDetail>) => void;
16 handleDelete: (id: number) => void;
17 handleEdit: (id: number) => void;
18}) {
19 const list = useRef<List>();
20
21 useEffect(() => {
22 const currentList = list.current;
23
24 currentList?.addEventListener("selection-change", handleSelectionChange as EventListener);
25 return () => {
26 currentList?.removeEventListener("selection-change", handleSelectionChange as EventListener);
27 };
28 }, [handleSelectionChange]);
29
30 return (
31 <ui5-list id="todo-list" selection-mode="Multiple" ref={list}>
32 {items.map((todo) => {
33 return <TodoItem key={todo.id} id={todo.id} text={todo.text} deadline={todo.deadline} done={todo.done} handleDelete={handleDelete} handleEdit={handleEdit}></TodoItem>;
34 })}
35 </ui5-list>
36 );
37}
38
39export default TodoList;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected