Skip to content
Advertisement

TypeError: ‘addcart’ is not a function in reactjs?

I made a page that contains products and they should add to the cart. But after connecting the backend from asp.net core to the products page, add to cart button is not working on the Product.js page.

JavaScript

context.js

JavaScript

Products.js

JavaScript

Also there is a problem in this details.js page backend data is showing on console.But it does not displaying as a user interface in frontend.

Details.js

JavaScript

Cart.js

JavaScript

Section.js

JavaScript

Advertisement

Answer

in Details.js this.setState({ products: res.data }); ===> this.setState({ product: res.data });. and use condition:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement