mardi 20 décembre 2016

jsx if else shorthand to hide element

I can do

<p>Company: </p>

but sometime company has no value. So how should I hide the entire

if the property of company is null?

I tried

<p>({this.state.user.company} ? 'Company: ' + {this.state.user.company} : '')</p>

But it doesn't work.

Aucun commentaire:

Enregistrer un commentaire