I need to render <tr> start and close it, based on a condition:
{grid.map((item, index) => {
return <React.Fragment key={index}>
{item.x === 0 ? <tr/> : ""}
<td id={`td_${item.x}_${item.y}`}>
{item.name}
</td>
</React.Fragment>
})}
Above code rendering all <td> tag outside of <tr> tag, but I want all <td> in <tr> tag.
In this code, I want <tr> start when item.x === 0 and need to render </tr> end in bottom this loop.
{grid.map((item, index) => {
return <React.Fragment key={index}>
{item.x === 0 ? <tr> : ""}
<td id={`td_${item.x}_${item.y}`}>
{item.name}
</td>
{item.x === 0 ? </tr> : ""}
</React.Fragment>
})}
This code showing error in jsx syntax error.
gridarray?