Skip to content

Instantly share code, notes, and snippets.

@hyber1z0r
Created August 10, 2020 20:07
Show Gist options
  • Save hyber1z0r/3c069994adb5d032fb6390bb59de2300 to your computer and use it in GitHub Desktop.
Save hyber1z0r/3c069994adb5d032fb6390bb59de2300 to your computer and use it in GitHub Desktop.
import React from 'react';
type Todo = {
id: number;
title: string;
completed: boolean;
}
type Props = {
todo: Todo;
}
const TodoItem = ({ todo }: Props) => {
return (
<li>{todo.title}</li>
)
};
const TodoList = () => {
const todos: Todo[] = [
{ id: 1, title: 'Buy nachos', completed: false },
{ id: 2, title: 'Buy avocado', completed: true },
{ id: 3, title: 'Buy ground beef', completed: false },
];
return (
<ul>
{todos.map((todo) => <TodoItem key={todo.id} todo={todo} />)}
</ul>
)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment