I have this problem. I want to loop an array and display the values as a table where each element is a row in the table. So far, no problems. But depending on a value in each element, I want to show an additional row with more values for each array element. I have this code:
<tbody>
{myList.map((item, i) => {
return (
<div>
<tr key={i} onClick={toggleMobileOpen.bind(this, i)}>
<td className=toggler>
{item.mobile_open && <ArrowUp />}
{!item.mobile_open && <ArrowDown />}
</td>
<td>{item.elem_one}</td>
<td>{item.elem_two}</td>
<td>{item.elem_three}</td>
</tr>
{item.mobile_open &&
<tr className=test-td>
<td>...</td>
</tr>
}
</div>
);
})}
</tbody>
My problem is that I get:
Warning: validateDOMNesting(...): Text nodes cannot appear as a child of <tr>.
and
Warning: validateDOMNesting(...): <div> cannot appear as a child of <tbody>
When I try the above approach. Removing the div gives me Syntax error
which I already knew but tried anyway.
Does anyone have an idea how to solve this?