I am having difficulty in a nested loop. My data is like this. You can see in the comment in the middle of my table, I tried to loop again the 'detail_info' but I can't make it. Please check the picture example output below the code.
I can't make the third loop in my second loop. Error says: JSX expressions must have one parent element.
const data =
[{
'product': {'value': 'Cotton'},
'detail': [{'document_no': 'DO234','quantity': '55',
'detail_info':[{'id': '1','expiry_date': '2018/10/12'},
{'id': '2','expiry_date': '2019/9/9'}]
}]
}]
<table className='scroll-table'>
<thead style={{'display':'table','width':'100%'}}>
<tr>
<th style={{'width':'20%'}}>Product</th>
<th style={{'width':'8%'}}>Doc. No</th>
<th style={{'width':'8%'}}>Quantity</th>
</tr>
</thead>
{data.map((item,idx)=>{
return(
<tbody key={idx} className="scrollbar">
<tr>
<td style={{'width':'2%'}}><input name="product" type="text" /></td>
</tr>
{item.detail.map((i,index)=>{
return(
<tr key={index} >
<td colSpan="2"></td>
<td>{i.document_no}</td>
<td >{i.quantity}</td>
</tr>
/* I want to loop here to make another <tr> but I
cant because **JSX expressions must have one parent element.
{i.detail_info.map((a,b)=>{
return(
<tr key={b}><td>{a.expiryDate}</td></tr>
)})
*/
)
})
</tbody>
)
})}
</table>
It should look like this.