Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

conditional style react

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>
  }
}
Source by malcoded.com #
 
PREVIOUS NEXT
Tagged: #conditional #style #react
ADD COMMENT
Topic
Name
9+7 =