0
I need to traverse an array within another array with array map
, in the first loop I will show the categories and in the second I will show the products, I am able to go through, but I cannot show the category of products.
Following example.
{menus.map(item =>
// ------------ não funciona ---------------------
<Header key={item.id}>
<Title>{item.no_categoria_cardapio}</Title>
</Header>
// ------------ fim não funciona ---------------------
// ------------ está funcionado ---------------------
item.produtos.map(product => (
<Card key={product.id}>
<CardHeader>
<Avatar
source={{
uri:
environment.apiImgBackend +
'/produtoCardapio/' +
product.img,
}}
/>
<CardInfo>
<NameCompanyView>
<NameCompany>
{product.nome}
</NameCompany>
</NameCompanyView>
<Description>
{product.descricao}
</Description>
</CardInfo>
</CardHeader>
</Card>
)),
// ------------ fim está funcionado ---------------------
)}
console.log(menus)
App screen.
one
console.log(menus)
and put here to show help answer your question!– novic
@Virgilionovic put more details
– Herick
you are having trouble printing this correct complex list, it is not that it is not coming is that it has a lot of component to manage correctly?
– novic
@Virgilionovic correct. the products I’m listing but the category of them I’m not getting. The commented part of the code. I’m not getting it all together for lack of jsx experience.
– Herick
@Virgilionovic wanted to do this. https://i.stack.Imgur.com/uyaqF.png
– Herick
the problem is to print several components on the same map this is your question!
– novic