In React I want to hide rows in the table using a value of the vehicle in a conditional rendering. The below code to hide/show row works only when used on a group of elements label and input, or with a select drop-down menu, but doesn't work on table rows.
return (
<Fragment>
<h2>Vehicle Details: {vehicle.vehicleId}</h2>
<table >
<tbody>
{vehicle.type = "car" && (
<Fragment>
<tr>
<th>Car</th>
<td>{vehicle.reg}</td>
</tr>
</Fragment>
)}
{vehicle.type = "truck" && (
<Fragment>
<tr>
<th>Truck</th>
<td>{vehicle.reg}</td>
</tr>
</Fragment>
)}
<tr>
<th>Bus</th>
<td>{vehicle.reg}</td>
</tr>
</tbody>
</table>
</Fragment>
);