I am trying to create a list of products using a set of data in react. I want to return the titles from this data and display it on screen in a list. I am trying to use a forEach loop but I'm. not sure exactly how to achieve this.
This is what I have so far:
import info from "./info";
import React from "react";
const ProductList = () => {
function listItems(item) {
return (
<Listbox.Option>
<Heading>{node.title}</Heading>
</Listbox.Option>
);
}
info.data.products.edges.forEach(listItems);
return listItems();
};
export default ProductList;
Can anyone tell me where I'm going wrong?