reactjs - How do you resolve Ternary operators with multiple ?'s and :'s in React -


{       this.props.favoritebutton ?         this.state.favorited ?           <div classname="star">&#9733;</div>         :           <div              classname="star"             onclick={() => this.favorite(recipe)}           >             &#9734;           </div>       :         <div></div>     } 

if there multiple ?'s before proceeding ternary statement in react mean both conditions have met meaning true? how statement work... quite confused on this...

after conversion simple ifs:

if (this.props.favoritebutton) {     if (this.state.favorited) {         return <div classname="star">&#9733;</div>;     } else {         return <div classname="star" onclick={() => this.favorite(recipe)}>&#9734;</div>;     } } else {     return <div></div> } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -