reactjs - How do you resolve Ternary operators with multiple ?'s and :'s in React -
{ this.props.favoritebutton ? this.state.favorited ? <div classname="star">★</div> : <div classname="star" onclick={() => this.favorite(recipe)} > ☆ </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">★</div>; } else { return <div classname="star" onclick={() => this.favorite(recipe)}>☆</div>; } } else { return <div></div> }
Comments
Post a Comment