Commit a90a99d4 authored by Vivian Che's avatar Vivian Che

add in check

parent c307fe49
import React, {useState, useEffect} from 'react'; import React, {useState} from 'react';
function GroceryList () { function GroceryList () {
const [list, setList] = useState([]) const [list, setList] = useState([])
const [item, setItem] = useState("") const [item, setItem] = useState("")
const [check, setCheck] = useState([])
const updateList = (e) => setList(e.target.value); const updateItem = (e) => setItem(e.target.value);
const handleSubmit = (e) => { const handleSubmit = () => {
const newItem = const newList = [...list, item]
setList(newList)
} }
console.log(list) console.log("LIST ", list)
console.log(item)
return ( return (
<div> <div>
<h1>Grocery List</h1> <h1>Grocery List</h1>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<input type="text" placeholder="Input" onChange={updateList} > <input type="text" placeholder="Input" value={item} onChange={updateItem} >
</input> </input>
<button type="submit">Add Item</button> <button type="submit">Add Item</button>
......
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