Answer the question
In order to leave comments, you need to log in
ReactJS should use forEach instead of map in this situation?
I am passing an array of objects to the component.
products = [{...},{...},{...}]
function GameProducts({products}) {
products.map((items) => {
<GameProduct product={items} />
});
}
function GameProduct({product}) {
const {img, title, desc, price, date} = product;
// ... рендеринг
}
Answer the question
In order to leave comments, you need to log in
This code won't work because it doesn't return anything.
products.map((items) => {
<GameProduct product={items} />
});
=> ({})
, or do this =>
:products.map(items =>
<GameProduct product={items} />
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question