Created
September 11, 2019 00:27
-
-
Save tkssharma/4193170bda6115e114155e79e4e1fc3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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