I'm trying to render data in a second render with JSON data mapping over it. I have to look over two objects to find matching product_ids
What am I doing wrong here?
{
this.props.productGroups.map((productGroup) => {
return (
<TabContainer key={productGroup.id}>
<h3>{productGroup.title}</h3>
{
productGroup.product_ids.map((productId) => {
this.props.products.map((product) => {
if (product.id == productId) {
return (
<div>
test
</div>
)
} else {
console.log('miss')
}
})
})
}
</TabContainer>
)
})
}
On a sidenote, I know this is callback hell, just not to sure on the best way of refactoring this.
productGroup.product_ids.map(function(productId)and do the same for the next one and doreturn.