Reputation: 39
I'm using React, and was wondering wether it is possible to highlight a table cell with a boolean, kind of this here:
<table>
<tr>
<td {if (highlight) bgColor = 'red'} >Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
</table>
(Where highlight is a boolean state variable).
Upvotes: 0
Views: 105
Reputation: 8412
Yes, you can. Simply use a ternary operator for that:
<td style={{backgroundColor: highlight ? 'red' : ''}} >Emil</td>
Upvotes: 1