Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created September 11, 2019 00:27
Show Gist options
  • Save tkssharma/4193170bda6115e114155e79e4e1fc3f to your computer and use it in GitHub Desktop.
Save tkssharma/4193170bda6115e114155e79e4e1fc3f to your computer and use it in GitHub Desktop.
function Todo() {
const [tasks, setTasks] = useState([
{
title: "Grab some Pizza",
completed: true
},
{
title: "Do your workout",
completed: true
},
{
title: "Hangout with friends",
completed: false
}
]);
const addTask = title => {
const newTasks = [...tasks, { title, completed: false }];
setTasks(newTasks);
};
return (
<div className="todo-container">
<div className="header">TODO - ITEMS</div>
<div className="tasks">
{tasks.map((task, index) => (
<Task
task={task}
index={index}
key={index}
/>
))}
</div>
<div className="create-task" >
<CreateTask addTask={addTask} />
</div>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment