Skip to content

Instantly share code, notes, and snippets.

@lydemann
Last active June 16, 2020 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/4a5f4c0cc70b03a693bbc38beee75273 to your computer and use it in GitHub Desktop.
Save lydemann/4a5f4c0cc70b03a693bbc38beee75273 to your computer and use it in GitHub Desktop.
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