Easy
You're debugging a performance issue in a React component. The team lead mentions that unnecessary re-renders might be the culprit. What's the problem in this code?
1function ProductCard({ product, onAddToCart }) {2 const formatPrice = (price) => {3 return new Intl.NumberFormat('en-US', {4 style: 'currency',5 currency: 'USD'6 }).format(price);7 };89 const formattedPrice = formatPrice(product.price);1011 return (12 <div className="product-card">13 <img src={product.image} alt={product.name} />14 <h3>{product.name}</h3>15 <p>{formattedPrice}</p>16 <button onClick={() => onAddToCart(product.id)}>17 Add to Cart18 </button>19 </div>20 );21}