I have been getting this error and even after few searches I have not been able to find the solution to it. I am new to node and javascript so any help will be cherished.
In written form the code is provided below:
import React, { useState } from "react";
export const ItemForm = ({ addItemProp }) => {
const [Name, setName] = useState("");
const [Price, setPrice] = useState("");
const [description, setdescription] = useState("");
const [Product, setProduct] = useState("");
const [imagepath, setimagepath] = useState("");
const [Category, setCategory] = useState("");
const addItem = _=> {
addItemProp({
id: (new Date).getTime(),
Name,
Price,
description,
Product,
Category,
imagepath,
});
setName('')
setPrice('');
setdescription('');
setProduct('');
setCategory('');
setimagepath('');
}
and the error I am getting is : TypeError: undefined is not a function (near '...addItemProp...') addItem src/Components/AddProduct/addProduct.jsx:14
13 | const addItem = _=> {
14 | addItemProp({
15 | id: (new Date).getTime(),
16 | Name,
17 | Price,