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 reactjs.org #
 
PREVIOUS NEXT
Tagged: #react #ternary #operator #html
ADD COMMENT
Topic
Name
3+6 =