Ternary operator on style with React Js Es 6

What you provide to style attribute should be an object. Since we write js code in jsx between curly braces, you ll insert an object there.

Remember, you need to camelCase all css props. ( font-size ==> fontSize )

<img 
  src={this.state.photo} 
  alt="" 
  style={ isLoggedIn ? { display:'block'} : {display : 'none'} }  
/>

or

<img
  src={this.state.photo} 
  alt=""
  style={ { display: isLoggedIn ? 'block' : 'none' } }  
/>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)