i am kind of stuck when working on an array of objects, so basically i am looking to make dynamic table using MaterialUI in React, but i am experience an error at <TableRow key={producNumber}>
as Expected an assignment or function call and instead saw an expression no-unused-expressions
not sure why it is happening as i tried to made a simple TableBody and in that i am going through each object in an array and display it, any suggestions guys.
function Basket({ basketItems, updatedBasket }) {
console.log(basketItems);
return (
<div className="BasketProducts">
<TableContainer component={Paper}>
<Table>
<TableHead>
<TableRow>
<TableCell> </TableCell>
<TableCell>Product Name </TableCell>
<TableCell> Item No.</TableCell>
<TableCell> StockLevel</TableCell>
<TableCell> Quantitiy</TableCell>
</TableRow>
</TableHead>
<TableBody>
{basketItems.map((eachproduct) => {
let productName = eachproduct.product_name;
let producNumber = eachproduct.producNumber;
let price = eachproduct.price;
let desc = eachproduct.productDescription;
let photo = eachproduct.image_URL;
let stockQuantity = eachproduct.stockQuantity;
<TableRow key={producNumber}> // the error is point to this position
<TableCell>
{" "}
<img className="BasketProducts-image" src={photo} />{" "}
</TableCell>
<TableCell>{productName}</TableCell>
<TableCell>{productName}</TableCell>
</TableRow>;
})}
</TableBody>
</Table>
</TableContainer>
</div>
);
}
the basketItem
is array of object as below, there are currently two but it can be more objects