Shopping cart

Report a typo

In your e-commerce application, a class component named AddToCartButton is present. Choose the correct implementation of the below given buttons that, when clicked, triggers a method named addToCart and logs "Item added to cart!" to the console.

import React, { Component } from "react";

class AddToCartButton extends Component {
  addToCart = () => {
    console.log("Item added to cart!");
  };

  render() {
    return ...
  }
}

export default AddToCartButton;
Select one or more options from the list

Create a free account to access the full topic