Skip to content

Instantly share code, notes, and snippets.

@lydemann

lydemann/todo-list.tsx

Last active Jun 16, 2020
Embed
What would you like to do?
todo-list.tsx
export const TodoList = () => {
const todoList = getTodoList();
useEffect(() => {
const crudItems = document.querySelectorAll('app-crud-item');
crudItems.forEach((item, idx) => {
(item as any).todoItem = todoList[idx];
});
});
return (
<div className='todo-list'>
{todoList.map((todoItem, i) => (
<app-crud-item
key={i}
is-read-only={true}
complete-btn-text='Complete'
></app-crud-item>
))}
</div>
);
};
const getTodoList = (): TodoItem[] => {
const todoList = [];
for (let index = 0; index < 5; index++) {
const newTodo = {
id: faker.random.uuid(),
title: faker.random.words(2),
description: faker.random.words(5),
};
todoList.push(newTodo);
}
return todoList;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.