Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ternary operator react

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: #ternary #operator #react
ADD COMMENT
Topic
Name
3+2 =