error in react when using semantic ui table

585 Views Asked by At

I using semantic UI to create a table. I want to set table row property to positive. like this :

<Table.Row positive>

here is my code:

  <Table.Row {this.props.email.success ? "positive" : "negative"}>

but this error is occure :

./src/components/EmailItem.js
Syntax error: ... src/components/EmailItem.js: Unexpected token, expected ... (7:18)

   5 |   render() {
   6 |     return (
>  7 |       <Table.Row {this.props.email.success ? "positive" : "negative"}>
     |                   ^
   8 |         <Table.Cell>
   9 |           {this.props.email.from}
  10 |         </Table.Cell>

how can i fix this ?

1

There are 1 best solutions below

0
On

Try this.

<Table.Row positive={!!this.props.email.success} negative={!this.props.email.success}>

And check this - How to conditionally add attributes to React components?