score:1

Accepted answer
import React.{useState,useEffect} from "react"
const { product } = props;
const [subTotal, setSubTotal] = useState(0);
const [itemQty, setItemQty] = useState(0);

useEffect(() => console.log(subTotal,itemQty),[subTotal,itemQty])

const handleCart = (event) => {
    const id = event.product.itemId;
    const price = event.product.price;
    setSubTotal(prev => {prev + Number(price)});
    setItemQty(prev => {prev + 1});
}

Related Query

More Query from same tag