This is a code repository for the corresponding video tutorial. In this video, we're going to build a fully functional eCommerce application using commerce.js.
This is video is awesome. I am experiencing a problem when adding items to the cart. This type Error appears on the web page
TypeError: onAddToCart is not a function can anyone help with this?
Below I have included the App.js, Products.js and Product.js code
App.js:
import React, { useState, useEffect } from 'react';
import { commerce } from './lib/commerce';
import { Products, Navbar } from './components';
Look at each example of "onAddtoCart" in yout files.. products.js and app.js has "onAddtoCart", but I see that product.js has "onAddToCart" with the "To" using uppercase. Change that and I think it will work.
This is video is awesome. I am experiencing a problem when adding items to the cart. This type Error appears on the web page TypeError: onAddToCart is not a function can anyone help with this?
Below I have included the App.js, Products.js and Product.js code
App.js:
import React, { useState, useEffect } from 'react'; import { commerce } from './lib/commerce'; import { Products, Navbar } from './components';
const App = () => { const [products, setProducts] = useState([]); const [cart, setCart] = useState({});
}
export default App
Products.js
import React from 'react';
import { Grid } from '@material-ui/core';
import Product from './Product/Product'; import useStyles from './styles';
const Products = ({ products, onAddToCart }) => { const classes = useStyles();
}
export default Products
Product.js
import React from 'react'; import { Card, CardMedia, CardContent, CardActions, Typography, IconButton } from '@material-ui/core'; import { AddShoppingCart } from '@material-ui/icons'; import useStyles from './styles';
const Product = ({ product, onAddToCart }) => { const classes = useStyles();
}
export default Product