Henrik
0
Q:

conditional style react

style={{ textDecoration: todo.completed && "line-through" }}

style={{ textDecoration: todo.completed ? "line-through" : 'none' }}
2
class App extends Component {
  constructor() {
    super()
    this.state = { isRed: true }
  }

  render() {
    const isRed = this.state.isRed

    return <p style={{ color: isRed ? 'red' : 'blue' }}>Example Text</p>
  }
}
2
<ImageBackground source={Images.bg} style={ (navHeight==0) ? styles.bg1 : styles.bg2}>
0

New to Communities?

Join the community