Commit f81f966d authored by Vivian Che's avatar Vivian Che

finish check

parent 82640a1a
......@@ -13,12 +13,22 @@ function GroceryList () {
setList(newList)
}
const handleCheck = () => {
const handleCheck = (e) => {
let checkedItems = [...check];
if (e.target.checked) {
checkedItems= [...check, e.target.value];
} else {
checkedItems.splice(check.indexOf(e.target.value), 1)
}
setCheck(checkedItems)
}
console.log("LIST ", list)
console.log(item)
console.log(check)
return (
<div>
......@@ -33,7 +43,7 @@ function GroceryList () {
{list.map((item, idx) => (
<div key={idx}>
<input type="checkbox" value={item} onChange={handleCheck} />
<p>{item}</p>
<p style={{textDecoration: check.includes(item) ? "line-through" : "none"}}>{item}</p>
</div>
))}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment