({item})
| 2 | import { ProductContext } from "../App"; |
| 3 | |
| 4 | function Product({item}){ |
| 5 | |
| 6 | const [addToCart,setAddToCart] = useState(false); |
| 7 | const {cartItem,setCartItem} = useContext(ProductContext); |
| 8 | |
| 9 | return( |
| 10 | <> |
| 11 | <div> |
| 12 | <h1>Name: {item.name}</h1> |
| 13 | <h2>Price: {item.price}</h2> |
| 14 | { |
| 15 | addToCart ? <button onClick={()=>{setAddToCart(false), setCartItem(cartItem=>cartItem-1)}}>Remove</button> : <button onClick={()=>{setAddToCart(true), setCartItem(cartItem=>cartItem+1)}}>Add</button> |
| 16 | } |
| 17 | </div> |
| 18 | </> |
| 19 | ) |
| 20 | } |
| 21 | |
| 22 | export default Product; |
nothing calls this directly
no outgoing calls
no test coverage detected