Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react ternary operator in html


render () {
  return (
    <div className="row">
      { //Check if message failed
        (this.state.message === 'failed')
          ? <div> Something went wrong </div> 
          : <div> Everything in the world is fine </div> 
      }
    </div>
  );
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #ternary #operator #html
ADD COMMENT
Topic
Name
4+7 =