I have created the following table in React.
The items I render have either category libraries or softwareComponents as category.
{
items.map((component: Components) =>
component.category === "libraries" ? (
<React.Fragment>
<tr>
<th>Libraries</th>
<th> </th>
</tr>
<tr key={component.name}>
<td>{component.name}</td>
<td>{component.version}</td>
</tr>
</React.Fragment>
) : (
<React.Fragment>
<tr>
<th>Software Components</th>
<th> </th>
</tr>
<tr key={component.name}>
<td>{component.name}</td>
<td>{component.version}</td>
</tr>
</React.Fragment>
)
);
}
The problem is that the subheader is rendered now every time but I only want to show it once.
